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.0.39 to 1.0.40

2

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

@@ -303,3 +303,3 @@ (function (global, factory) {

self.addEventListener('message', function (event) {
if (event.data instanceof String && event.data.indexOf("give me response ") == -1)
if (!(event.data instanceof String) || event.data.indexOf("give me response ") == -1)
return;

@@ -306,0 +306,0 @@ var key = event.data.substr(17);

@@ -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.passThroughDB(e):this.resolveNow(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(!(e.data instanceof String&&-1==e.data.indexOf("give me response "))){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)}},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.passThroughDB(e):this.resolveNow(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(e.data instanceof String&&-1!=e.data.indexOf("give me response ")){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)}},Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "ng-http-sw-proxy",
"version": "1.0.39",
"version": "1.0.40",
"description": "An amazing module for Angular.",

@@ -5,0 +5,0 @@ "main": "bundles/ng-http-sw-proxy.umd.js",

@@ -67,3 +67,3 @@ import { Store } from '../src/store';

self.addEventListener('message', function (event) {
if (event.data instanceof String && event.data.indexOf("give me response ") == -1)
if (!(event.data instanceof String) || event.data.indexOf("give me response ") == -1)
return;

@@ -70,0 +70,0 @@ var key = event.data.substr(17);

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