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.23 to 1.0.24

4

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

@@ -324,9 +324,7 @@ (function (global, factory) {

console.log("got event! message!");
//this.responsesReady.subscribe((id: number) => {
// console.log("response " + id + " is ready");
event.ports[0].postMessage(" checking if I have response " + key);
console.log(_this.promiseRegister);
_this.promiseRegister.get(parseInt(key)).then(function (value) {
console.log("response " + key + " is waiting");
});
//});
});

@@ -333,0 +331,0 @@ }

@@ -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,o,n,r,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(o){return t.db.transaction("requests",e).objectStore("requests")})},e.prototype.responses=function(e){var t=this;return this.init().then(function(o){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,o){var n=this;this.http=t,this.store=o,this.obsRegister=new Map,this.isConnected=!1,this.platformId=e,this.hasNetworkConnection().subscribe(function(e){return n.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,o){return this.resolveRequest({method:a.POST,url:e,options:o,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,o){return this.resolveRequest({method:a.PATCH,url:e,options:o,body:t})},e.prototype.put=function(e,t,o){return this.resolveRequest({method:a.PUT,url:e,options:o,body:t})},e.prototype.request=function(e,t){return this.resolveRequest({method:a.REQUEST,url:e,options:t})},e.prototype.hasNetworkConnection=function(){return n.isPlatformBrowser(this.platformId)?r.Observable.merge(r.Observable.of(navigator.onLine),r.Observable.fromEvent(window,"online").map(function(){return!0}),r.Observable.fromEvent(window,"offline").map(function(){return!1})):r.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 console.log("pass to db"),r.Observable.create(function(o){console.log("in observable"),t.store.requests("readwrite").then(function(t){return t.put(e)}).then(function(e){console.log("stored"),"production"==process.env.NODE_ENV&&"serviceWorker"in navigator?(console.log("service worker present"),navigator.serviceWorker.ready.then(function(n){console.log("service worker ready"),n.sync.register("request");var r=new MessageChannel;r.port1.onmessage=function(e){console.log("got response"),console.log(e)},navigator.serviceWorker.controller.postMessage("give me response "+e,[r.port2]),console.log("invoked sync"),t.getResponseFromDB(e).subscribe(function(e){return o.next(e)})})):t.waitForConnectionAndSend(e).subscribe(function(e){return o.next(e)})})})},e.prototype.getResponseFromDB=function(e){var o=this;return r.Observable.create(function(n){var r;r=setInterval(function(){o.store.responses("readwrite").then(function(o){return o.get(e).then(function(s){if(s){clearInterval(r),o.delete(e);for(var i=void 0,u=new t.Headers,a=0,p=s.response.headers.entries();a<p.length;a++){var c=p[a];u.set(c[0],c[1])}var d=t.ResponseType.Basic;switch(s.response.type){case"basic":d=t.ResponseType.Basic}var l=new t.ResponseOptions({body:s.response.body,status:s.response.status,headers:u,statusText:s.response.statusText,type:d,url:s.response.url});(i=new t.Response(l)).ok?n.next(i):n.error(i),n.complete}})})},100)})},e.prototype.waitForConnectionAndSend=function(e){var t,o=this;return this.hasNetworkConnection().filter(function(e){return e}).subscribe(function(){o.store.requests("readonly").then(function(n){n.get(e).then(function(e){t=o.resolveNow(e),n.delete(e.id)})})}),t},e}();p.decorators=[{type:o.Injectable}],p.ctorParameters=function(){return[{type:Object,decorators:[{type:o.Inject,args:[o.PLATFORM_ID]}]},{type:t.Http},{type:u}]};var c=function(){return function(){}}();c.decorators=[{type:o.NgModule,args:[{imports:[t.HttpModule],providers:[p,u]}]}],c.ctorParameters=function(){return[]};var d=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 o;t.promiseRegister.set(e.id,new Promise(function(e){return o=e}));var n={method:e.method,body:e.body,cache:"no-store",headers:t.getHeaders(e.body)};return fetch(e.url,n).then(function(n){t.store.requests("readwrite").then(function(t){t.delete(e.id)});var r,s={type:n.type,bodyUsed:n.bodyUsed,body:{},headers:new Map,ok:n.ok,status:n.status,statusText:n.statusText,url:n.url};return n.headers.has("content-type")&&(r=n.headers.get("content-type").indexOf("json")>-1?n.json():n.headers.get("content-type").indexOf("text")>-1?n.text():n.headers.get("content-type").indexOf("application/x-www-form-urlencoded")>-1?n.formData():n.headers.get("content-type").indexOf("application/octet-stream")>-1?n.blob():n.arrayBuffer()),n.headers.forEach(function(e,t){s.headers.set(e,t)}),r.then(function(n){return s.body=n,t.store.responses("readwrite").then(function(t){t.put({id:e.id,response:s}),o(!0)}),t.store.closeTransaction()})})}))}))}),self.addEventListener("message",function(e){if(-1!=e.data.indexOf("give me response ")){var o=e.data.substr(17);console.log("got event! message!"),e.ports[0].postMessage(" checking if I have response "+o),t.promiseRegister.get(parseInt(o)).then(function(e){console.log("response "+o+" is waiting")})}})}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 d(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,o,n,r,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(o){return t.db.transaction("requests",e).objectStore("requests")})},e.prototype.responses=function(e){var t=this;return this.init().then(function(o){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,o){var n=this;this.http=t,this.store=o,this.obsRegister=new Map,this.isConnected=!1,this.platformId=e,this.hasNetworkConnection().subscribe(function(e){return n.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,o){return this.resolveRequest({method:a.POST,url:e,options:o,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,o){return this.resolveRequest({method:a.PATCH,url:e,options:o,body:t})},e.prototype.put=function(e,t,o){return this.resolveRequest({method:a.PUT,url:e,options:o,body:t})},e.prototype.request=function(e,t){return this.resolveRequest({method:a.REQUEST,url:e,options:t})},e.prototype.hasNetworkConnection=function(){return n.isPlatformBrowser(this.platformId)?r.Observable.merge(r.Observable.of(navigator.onLine),r.Observable.fromEvent(window,"online").map(function(){return!0}),r.Observable.fromEvent(window,"offline").map(function(){return!1})):r.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 console.log("pass to db"),r.Observable.create(function(o){console.log("in observable"),t.store.requests("readwrite").then(function(t){return t.put(e)}).then(function(e){console.log("stored"),"production"==process.env.NODE_ENV&&"serviceWorker"in navigator?(console.log("service worker present"),navigator.serviceWorker.ready.then(function(n){console.log("service worker ready"),n.sync.register("request");var r=new MessageChannel;r.port1.onmessage=function(e){console.log("got response"),console.log(e)},navigator.serviceWorker.controller.postMessage("give me response "+e,[r.port2]),console.log("invoked sync"),t.getResponseFromDB(e).subscribe(function(e){return o.next(e)})})):t.waitForConnectionAndSend(e).subscribe(function(e){return o.next(e)})})})},e.prototype.getResponseFromDB=function(e){var o=this;return r.Observable.create(function(n){var r;r=setInterval(function(){o.store.responses("readwrite").then(function(o){return o.get(e).then(function(s){if(s){clearInterval(r),o.delete(e);for(var i=void 0,u=new t.Headers,a=0,p=s.response.headers.entries();a<p.length;a++){var c=p[a];u.set(c[0],c[1])}var l=t.ResponseType.Basic;switch(s.response.type){case"basic":l=t.ResponseType.Basic}var d=new t.ResponseOptions({body:s.response.body,status:s.response.status,headers:u,statusText:s.response.statusText,type:l,url:s.response.url});(i=new t.Response(d)).ok?n.next(i):n.error(i),n.complete}})})},100)})},e.prototype.waitForConnectionAndSend=function(e){var t,o=this;return this.hasNetworkConnection().filter(function(e){return e}).subscribe(function(){o.store.requests("readonly").then(function(n){n.get(e).then(function(e){t=o.resolveNow(e),n.delete(e.id)})})}),t},e}();p.decorators=[{type:o.Injectable}],p.ctorParameters=function(){return[{type:Object,decorators:[{type:o.Inject,args:[o.PLATFORM_ID]}]},{type:t.Http},{type:u}]};var c=function(){return function(){}}();c.decorators=[{type:o.NgModule,args:[{imports:[t.HttpModule],providers:[p,u]}]}],c.ctorParameters=function(){return[]};var l=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 o;t.promiseRegister.set(e.id,new Promise(function(e){return o=e}));var n={method:e.method,body:e.body,cache:"no-store",headers:t.getHeaders(e.body)};return fetch(e.url,n).then(function(n){t.store.requests("readwrite").then(function(t){t.delete(e.id)});var r,s={type:n.type,bodyUsed:n.bodyUsed,body:{},headers:new Map,ok:n.ok,status:n.status,statusText:n.statusText,url:n.url};return n.headers.has("content-type")&&(r=n.headers.get("content-type").indexOf("json")>-1?n.json():n.headers.get("content-type").indexOf("text")>-1?n.text():n.headers.get("content-type").indexOf("application/x-www-form-urlencoded")>-1?n.formData():n.headers.get("content-type").indexOf("application/octet-stream")>-1?n.blob():n.arrayBuffer()),n.headers.forEach(function(e,t){s.headers.set(e,t)}),r.then(function(n){return s.body=n,t.store.responses("readwrite").then(function(t){t.put({id:e.id,response:s}),o(!0)}),t.store.closeTransaction()})})}))}))}),self.addEventListener("message",function(e){if(-1!=e.data.indexOf("give me response ")){var o=e.data.substr(17);console.log("got event! message!"),e.ports[0].postMessage(" checking if I have response "+o),console.log(t.promiseRegister),t.promiseRegister.get(parseInt(o)).then(function(e){console.log("response "+o+" is waiting")})}})}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 l(e)}},Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "ng-http-sw-proxy",
"version": "1.0.23",
"version": "1.0.24",
"description": "An amazing module for Angular.",

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

@@ -79,9 +79,7 @@ import { Store } from '../src/store';

console.log("got event! message!");
//this.responsesReady.subscribe((id: number) => {
// console.log("response " + id + " is ready");
event.ports[0].postMessage(" checking if I have response " + key);
console.log(_this.promiseRegister);
_this.promiseRegister.get(parseInt(key)).then(function (value) {
console.log("response " + key + " is waiting");
});
//});
});

@@ -88,0 +86,0 @@ }

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