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

ng-http-sw-proxy

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng-http-sw-proxy - npm Package Compare versions

Comparing version 1.2.1 to 1.2.7

40

dist/bundles/ng-http-sw-proxy.umd.js

@@ -209,14 +209,14 @@ (function (global, factory) {

};
HttpSwProxy.decorators = [
{ type: _angular_core.Injectable },
];
/** @nocollapse */
HttpSwProxy.ctorParameters = function () { return [
{ type: Object, decorators: [{ type: _angular_core.Inject, args: [_angular_core.PLATFORM_ID,] },] },
{ type: _angular_http.Http, },
{ type: Store, },
{ type: _angular_core.ApplicationRef, },
]; };
return HttpSwProxy;
}());
HttpSwProxy.decorators = [
{ type: _angular_core.Injectable },
];
/** @nocollapse */
HttpSwProxy.ctorParameters = function () { return [
{ type: Object, decorators: [{ type: _angular_core.Inject, args: [_angular_core.PLATFORM_ID,] },] },
{ type: _angular_http.Http, },
{ type: Store, },
{ type: _angular_core.ApplicationRef, },
]; };

@@ -226,14 +226,14 @@ var HttpSwProxyModule = (function () {

}
HttpSwProxyModule.decorators = [
{ type: _angular_core.NgModule, args: [{
imports: [
_angular_http.HttpModule
],
providers: [HttpSwProxy, Store]
},] },
];
/** @nocollapse */
HttpSwProxyModule.ctorParameters = function () { return []; };
return HttpSwProxyModule;
}());
HttpSwProxyModule.decorators = [
{ type: _angular_core.NgModule, args: [{
imports: [
_angular_http.HttpModule
],
providers: [HttpSwProxy, Store]
},] },
];
/** @nocollapse */
HttpSwProxyModule.ctorParameters = function () { return []; };

@@ -240,0 +240,0 @@ function HttpSwProxyPlugin() {

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/http"),require("@angular/core"),require("@angular/common"),require("rxjs"),require("idb")):"function"==typeof define&&define.amd?define(["exports","@angular/http","@angular/core","@angular/common","rxjs","idb"],t):t((e.ng=e.ng||{},e.ng["http-sw-proxy"]=e.ng["http-sw-proxy"]||{}),e.ng.http,e.ng.core,e.ng.common,e.Rx,e.idb)}(this,function(e,t,n,r,o,s){"use strict";var i=s.default,u=function(){function e(){this.db=null}return e.prototype.init=function(){var e=this;return this.db?Promise.resolve(this.db):i.open("restRequest",1,function(e){e.createObjectStore("requests",{autoIncrement:!0,keyPath:"id"}),e.createObjectStore("responses",{keyPath:"id",autoIncrement:!1})}).then(function(t){return e.db=t})},e.prototype.requests=function(e){var t=this;return this.init().then(function(n){return t.db.transaction("requests",e).objectStore("requests")})},e.prototype.responses=function(e){var t=this;return this.init().then(function(n){return t.db.transaction("responses",e).objectStore("responses")})},e.prototype.closeTransaction=function(){return this.db.transaction.complete},e}(),a={DELETE:"DELETE",GET:"GET",HEAD:"HEAD",OPTIONS:"OPTIONS",PATCH:"PATCH",POST:"POST",PUT:"PUT",REQUEST:"REQUEST"},p=function(){function e(e,t,n,r){var o=this;this.http=t,this.store=n,this.appref=r,this.obsRegister=new Map,this.isConnected=!1,this.platformId=e,this.hasNetworkConnection().subscribe(function(e){return o.isConnected=e})}return e.prototype.get=function(e,t){return this.resolveRequest({method:a.GET,url:e,options:t})},e.prototype.post=function(e,t,n){return this.resolveRequest({method:a.POST,url:e,options:n,body:t})},e.prototype.delete=function(e,t){return this.resolveRequest({method:a.DELETE,url:e,options:t})},e.prototype.head=function(e,t){return this.resolveRequest({method:a.HEAD,url:e,options:t})},e.prototype.options=function(e,t){return this.resolveRequest({method:a.OPTIONS,url:e,options:t})},e.prototype.patch=function(e,t,n){return this.resolveRequest({method:a.PATCH,url:e,options:n,body:t})},e.prototype.put=function(e,t,n){return this.resolveRequest({method:a.PUT,url:e,options:n,body:t})},e.prototype.request=function(e,t){return this.resolveRequest({method:a.REQUEST,url:e,options:t})},e.prototype.hasNetworkConnection=function(){return r.isPlatformBrowser(this.platformId)?o.Observable.merge(o.Observable.of(navigator.onLine),o.Observable.fromEvent(window,"online").map(function(){return!0}),o.Observable.fromEvent(window,"offline").map(function(){return!1})):o.Observable.of(!0)},e.prototype.resolveRequest=function(e){return this.isConnected?this.resolveNow(e):this.passThroughDB(e)},e.prototype.resolveNow=function(e){var t;switch(e.method){default:t=this.http.get(e.url,e.options);break;case a.POST:t=this.http.post(e.url,e.body,e.options);break;case a.DELETE:t=this.http.delete(e.url,e.options);break;case a.HEAD:t=this.http.head(e.url,e.options);break;case a.OPTIONS:t=this.http.options(e.url,e.options);break;case a.PATCH:t=this.http.patch(e.url,e.body,e.options);break;case a.PUT:t=this.http.put(e.url,e.body,e.options);break;case a.REQUEST:t=this.http.request(e.url,e.options)}return t},e.prototype.passThroughDB=function(e){var t=this;return o.Observable.create(function(n){t.store.requests("readwrite").then(function(t){return t.put(e)}).then(function(e){t.obsRegister.set(e,n),"production"==process.env.NODE_ENV&&"serviceWorker"in navigator?navigator.serviceWorker.ready.then(function(r){r.sync.register("request");var o=new MessageChannel;o.port1.onmessage=function(r){t.getResponseFromDB(e).subscribe(function(e){return n.next(e)})},navigator.serviceWorker.controller.postMessage("give me response "+e,[o.port2])}):t.waitForConnectionAndSend()})})},e.prototype.getResponseFromDB=function(e){var n=this;return o.Observable.create(function(r){n.store.responses("readwrite").then(function(o){return o.get(e).then(function(s){o.delete(e);for(var i,u=new t.Headers,a=t.ResponseType.Basic,p=0,c=s.response.headers.entries();p<c.length;p++){var h=c[p];u.set(h[0],h[1])}switch(s.response.type){case"basic":a=t.ResponseType.Basic}var d=new t.ResponseOptions({body:s.response.body,status:s.response.status,headers:u,statusText:s.response.statusText,type:a,url:s.response.url});(i=new t.Response(d)).ok?r.next(i):r.error(i),r.complete,n.appref.tick()})})})},e.prototype.waitForConnectionAndSend=function(){var e=this;this.hasNetworkConnection().filter(function(e){return e}).subscribe(function(){e.store.requests("readwrite").then(function(t){t.getAll().then(function(n){n.forEach(function(n){t.delete(n.id),e.obsRegister.has(n.id)&&e.resolveNow(n).subscribe(function(t){return e.obsRegister.get(n.id).next(t)})})})})})},e}();p.decorators=[{type:n.Injectable}],p.ctorParameters=function(){return[{type:Object,decorators:[{type:n.Inject,args:[n.PLATFORM_ID]}]},{type:t.Http},{type:u},{type:n.ApplicationRef}]};var c=function(){return function(){}}();c.decorators=[{type:n.NgModule,args:[{imports:[t.HttpModule],providers:[p,u]}]}],c.ctorParameters=function(){return[]};var h=function(){function e(e){var t=this;this.worker=e,this.promiseRegister=new Map,this.store=new u,self.addEventListener("sync",function(e){e.waitUntil(t.store.requests("readonly").then(function(e){return e.getAll()}).then(function(e){return Promise.all(e.map(function(e){var n;return t.promiseRegister.set(e.id,new Promise(function(e){return n=e})),fetch(e.url,{method:e.method,body:JSON.stringify(e.body),cache:"no-store",headers:t.getHeaders(e.body)}).then(function(r){t.store.requests("readwrite").then(function(t){return t.delete(e.id)});var o,s={type:r.type,bodyUsed:r.bodyUsed,body:{},headers:new Map,ok:r.ok,status:r.status,statusText:r.statusText,url:r.url};return r.headers.has("content-type")&&(o=r.headers.get("content-type").indexOf("json")>-1?r.json():r.headers.get("content-type").indexOf("text")>-1?r.text():r.headers.get("content-type").indexOf("application/x-www-form-urlencoded")>-1?r.formData():r.headers.get("content-type").indexOf("application/octet-stream")>-1?r.blob():r.arrayBuffer()),r.headers.forEach(function(e,t){s.headers.set(e,t)}),o.then(function(r){return s.body=r,t.store.responses("readwrite").then(function(t){t.put({id:e.id,response:s}),n(!0)}),t.store.closeTransaction()})})}))}))}),self.addEventListener("message",function(e){if("string"==typeof e.data&&e.data.indexOf("give me response ")>-1){var n,r=e.data.substr(17);n=setInterval(function(){t.promiseRegister.has(parseInt(r))&&(clearInterval(n),t.promiseRegister.get(parseInt(r)).then(function(n){e.ports[0].postMessage("response is waiting: "+r),t.promiseRegister.delete(parseInt(r))}))},1)}})}return e.prototype.setup=function(e){},e.prototype.getContentType=function(e){return e instanceof URLSearchParams?"application/x-www-form-urlencoded":e instanceof FormData?"multipart/form-data":e instanceof Blob?"application/octet-stream":e&&"object"==typeof e?"application/json":"text/plain"},e.prototype.getHeaders=function(e){var t=new Headers;return null!=e&&t.set("Content-Type",this.getContentType(e)),t},e}();e.HttpSwProxyModule=c,e.Store=u,e.HttpSwProxy=p,e.HttpSwProxyPlugin=function(){return function(e){return new h(e)}},e.HttpSwProxyPluginImpl=h,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/http"),require("@angular/core"),require("@angular/common"),require("rxjs"),require("idb")):"function"==typeof define&&define.amd?define(["exports","@angular/http","@angular/core","@angular/common","rxjs","idb"],t):t((e.ng=e.ng||{},e.ng["http-sw-proxy"]=e.ng["http-sw-proxy"]||{}),e.ng.http,e.ng.core,e.ng.common,e.Rx,e.idb)}(this,function(e,t,n,r,o,s){"use strict";var i=s.default,u=function(){function e(){this.db=null}return e.prototype.init=function(){var e=this;return this.db?Promise.resolve(this.db):i.open("restRequest",1,function(e){e.createObjectStore("requests",{autoIncrement:!0,keyPath:"id"}),e.createObjectStore("responses",{keyPath:"id",autoIncrement:!1})}).then(function(t){return e.db=t})},e.prototype.requests=function(e){var t=this;return this.init().then(function(n){return t.db.transaction("requests",e).objectStore("requests")})},e.prototype.responses=function(e){var t=this;return this.init().then(function(n){return t.db.transaction("responses",e).objectStore("responses")})},e.prototype.closeTransaction=function(){return this.db.transaction.complete},e}(),a={DELETE:"DELETE",GET:"GET",HEAD:"HEAD",OPTIONS:"OPTIONS",PATCH:"PATCH",POST:"POST",PUT:"PUT",REQUEST:"REQUEST"},p=function(){function e(e,t,n,r){var o=this;this.http=t,this.store=n,this.appref=r,this.obsRegister=new Map,this.isConnected=!1,this.platformId=e,this.hasNetworkConnection().subscribe(function(e){return o.isConnected=e})}return e.prototype.get=function(e,t){return this.resolveRequest({method:a.GET,url:e,options:t})},e.prototype.post=function(e,t,n){return this.resolveRequest({method:a.POST,url:e,options:n,body:t})},e.prototype.delete=function(e,t){return this.resolveRequest({method:a.DELETE,url:e,options:t})},e.prototype.head=function(e,t){return this.resolveRequest({method:a.HEAD,url:e,options:t})},e.prototype.options=function(e,t){return this.resolveRequest({method:a.OPTIONS,url:e,options:t})},e.prototype.patch=function(e,t,n){return this.resolveRequest({method:a.PATCH,url:e,options:n,body:t})},e.prototype.put=function(e,t,n){return this.resolveRequest({method:a.PUT,url:e,options:n,body:t})},e.prototype.request=function(e,t){return this.resolveRequest({method:a.REQUEST,url:e,options:t})},e.prototype.hasNetworkConnection=function(){return r.isPlatformBrowser(this.platformId)?o.Observable.merge(o.Observable.of(navigator.onLine),o.Observable.fromEvent(window,"online").map(function(){return!0}),o.Observable.fromEvent(window,"offline").map(function(){return!1})):o.Observable.of(!0)},e.prototype.resolveRequest=function(e){return this.isConnected?this.resolveNow(e):this.passThroughDB(e)},e.prototype.resolveNow=function(e){var t;switch(e.method){default:t=this.http.get(e.url,e.options);break;case a.POST:t=this.http.post(e.url,e.body,e.options);break;case a.DELETE:t=this.http.delete(e.url,e.options);break;case a.HEAD:t=this.http.head(e.url,e.options);break;case a.OPTIONS:t=this.http.options(e.url,e.options);break;case a.PATCH:t=this.http.patch(e.url,e.body,e.options);break;case a.PUT:t=this.http.put(e.url,e.body,e.options);break;case a.REQUEST:t=this.http.request(e.url,e.options)}return t},e.prototype.passThroughDB=function(e){var t=this;return o.Observable.create(function(n){t.store.requests("readwrite").then(function(t){return t.put(e)}).then(function(e){t.obsRegister.set(e,n),"production"==process.env.NODE_ENV&&"serviceWorker"in navigator?navigator.serviceWorker.ready.then(function(r){r.sync.register("request");var o=new MessageChannel;o.port1.onmessage=function(r){t.getResponseFromDB(e).subscribe(function(e){return n.next(e)})},navigator.serviceWorker.controller.postMessage("give me response "+e,[o.port2])}):t.waitForConnectionAndSend()})})},e.prototype.getResponseFromDB=function(e){var n=this;return o.Observable.create(function(r){n.store.responses("readwrite").then(function(o){return o.get(e).then(function(s){o.delete(e);for(var i,u=new t.Headers,a=t.ResponseType.Basic,p=0,c=s.response.headers.entries();p<c.length;p++){var h=c[p];u.set(h[0],h[1])}switch(s.response.type){case"basic":a=t.ResponseType.Basic}var d=new t.ResponseOptions({body:s.response.body,status:s.response.status,headers:u,statusText:s.response.statusText,type:a,url:s.response.url});(i=new t.Response(d)).ok?r.next(i):r.error(i),r.complete,n.appref.tick()})})})},e.prototype.waitForConnectionAndSend=function(){var e=this;this.hasNetworkConnection().filter(function(e){return e}).subscribe(function(){e.store.requests("readwrite").then(function(t){t.getAll().then(function(n){n.forEach(function(n){t.delete(n.id),e.obsRegister.has(n.id)&&e.resolveNow(n).subscribe(function(t){return e.obsRegister.get(n.id).next(t)})})})})})},e.decorators=[{type:n.Injectable}],e.ctorParameters=function(){return[{type:Object,decorators:[{type:n.Inject,args:[n.PLATFORM_ID]}]},{type:t.Http},{type:u},{type:n.ApplicationRef}]},e}(),c=function(){function e(){}return e.decorators=[{type:n.NgModule,args:[{imports:[t.HttpModule],providers:[p,u]}]}],e.ctorParameters=function(){return[]},e}(),h=function(){function e(e){var t=this;this.worker=e,this.promiseRegister=new Map,this.store=new u,self.addEventListener("sync",function(e){e.waitUntil(t.store.requests("readonly").then(function(e){return e.getAll()}).then(function(e){return Promise.all(e.map(function(e){var n;return t.promiseRegister.set(e.id,new Promise(function(e){return n=e})),fetch(e.url,{method:e.method,body:JSON.stringify(e.body),cache:"no-store",headers:t.getHeaders(e.body)}).then(function(r){t.store.requests("readwrite").then(function(t){return t.delete(e.id)});var o,s={type:r.type,bodyUsed:r.bodyUsed,body:{},headers:new Map,ok:r.ok,status:r.status,statusText:r.statusText,url:r.url};return r.headers.has("content-type")&&(o=r.headers.get("content-type").indexOf("json")>-1?r.json():r.headers.get("content-type").indexOf("text")>-1?r.text():r.headers.get("content-type").indexOf("application/x-www-form-urlencoded")>-1?r.formData():r.headers.get("content-type").indexOf("application/octet-stream")>-1?r.blob():r.arrayBuffer()),r.headers.forEach(function(e,t){s.headers.set(e,t)}),o.then(function(r){return s.body=r,t.store.responses("readwrite").then(function(t){t.put({id:e.id,response:s}),n(!0)}),t.store.closeTransaction()})})}))}))}),self.addEventListener("message",function(e){if("string"==typeof e.data&&e.data.indexOf("give me response ")>-1){var n,r=e.data.substr(17);n=setInterval(function(){t.promiseRegister.has(parseInt(r))&&(clearInterval(n),t.promiseRegister.get(parseInt(r)).then(function(n){e.ports[0].postMessage("response is waiting: "+r),t.promiseRegister.delete(parseInt(r))}))},1)}})}return e.prototype.setup=function(e){},e.prototype.getContentType=function(e){return e instanceof URLSearchParams?"application/x-www-form-urlencoded":e instanceof FormData?"multipart/form-data":e instanceof Blob?"application/octet-stream":e&&"object"==typeof e?"application/json":"text/plain"},e.prototype.getHeaders=function(e){var t=new Headers;return null!=e&&t.set("Content-Type",this.getContentType(e)),t},e}();e.HttpSwProxyModule=c,e.Store=u,e.HttpSwProxy=p,e.HttpSwProxyPlugin=function(){return function(e){return new h(e)}},e.HttpSwProxyPluginImpl=h,Object.defineProperty(e,"__esModule",{value:!0})});

@@ -8,15 +8,15 @@ import { HttpModule } from '@angular/http';

}
HttpSwProxyModule.decorators = [
{ type: NgModule, args: [{
imports: [
HttpModule
],
providers: [HttpSwProxy, Store]
},] },
];
/** @nocollapse */
HttpSwProxyModule.ctorParameters = function () { return []; };
return HttpSwProxyModule;
}());
export { HttpSwProxyModule };
HttpSwProxyModule.decorators = [
{ type: NgModule, args: [{
imports: [
HttpModule
],
providers: [HttpSwProxy, Store]
},] },
];
/** @nocollapse */
HttpSwProxyModule.ctorParameters = function () { return []; };
//# sourceMappingURL=http-sw-proxy.module.js.map

@@ -162,15 +162,15 @@ import { Http, Response, ResponseOptions, ResponseType, Headers } from '@angular/http';

};
HttpSwProxy.decorators = [
{ type: Injectable },
];
/** @nocollapse */
HttpSwProxy.ctorParameters = function () { return [
{ type: Object, decorators: [{ type: Inject, args: [PLATFORM_ID,] },] },
{ type: Http, },
{ type: Store, },
{ type: ApplicationRef, },
]; };
return HttpSwProxy;
}());
export { HttpSwProxy };
HttpSwProxy.decorators = [
{ type: Injectable },
];
/** @nocollapse */
HttpSwProxy.ctorParameters = function () { return [
{ type: Object, decorators: [{ type: Inject, args: [PLATFORM_ID,] },] },
{ type: Http, },
{ type: Store, },
{ type: ApplicationRef, },
]; };
//# sourceMappingURL=http-sw-proxy.service.js.map
{
"name": "ng-http-sw-proxy",
"version": "1.2.1",
"version": "1.2.7",
"description": "Proxy for angular http service. Schedules request send in service-worker and/or IndexedDB.",

@@ -20,2 +20,3 @@ "main": "dist/bundles/ng-http-sw-proxy.umd.js",

"scripts": {
"test": "",
"transpile": "ngc",

@@ -25,3 +26,3 @@ "package": "rollup -c",

"build": "rimraf dist && npm run transpile && npm run package && npm run minify",
"prepublish": "npm run build"
"prepublishOnly": "npm run build"
},

@@ -54,3 +55,3 @@ "keywords": [

"@angular/compiler-cli": "^4.2.4",
"@types/node": "^8.0.6",
"@types/node": "^8.0.7",
"rimraf": "^2.6.1",

@@ -57,0 +58,0 @@ "rollup": "^0.43.0",

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