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

@obelisk/client

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@obelisk/client - npm Package Compare versions

Comparing version 2.1.1 to 2.1.2

43

lib/api/stream-endpoint.js

@@ -5,4 +5,4 @@ "use strict";

const rxjs_1 = require("rxjs");
const operators_1 = require("rxjs/operators");
const util_1 = require("../util");
const operators_1 = require("rxjs/operators");
/**

@@ -50,34 +50,25 @@ * Endpoint class represents an IoT-stack API Endpoint.

observablePolyEventSource(options) {
const start = Date.now();
const url = options ? this.addOptionsToUrl(this._url, options) : this._url;
const h = {
headers: { Authorization: 'Bearer ' + (this.client.tokens.rpt ? this.client.tokens.rpt.getToken() : '<no rpt present>') },
Transport: XMLHttpRequest
Transport: XMLHttpRequest,
};
const subject = new rxjs_1.ReplaySubject(1);
const eventsource = new event_source_polyfill_1.EventSourcePolyfill(url, h);
return rxjs_1.Observable.create((observer) => {
if (util_1.Config.debug) {
// console.log(eventsource);
eventsource.onopen = function () {
console.log(Date.now() - start);
};
eventsource.onmessage = function (event) {
const json = JSON.parse(event.data);
subject.next(json);
};
eventsource.onerror = function (event) {
eventsource.close();
if (eventsource.readyState === 0) { // connecting
subject.complete();
}
eventsource.onmessage = function (event) {
const json = JSON.parse(event.data);
observer.next(json);
};
eventsource.onerror = function (event) {
eventsource.close();
if (eventsource.readyState === 0) {
observer.complete();
}
else {
observer.error(event);
}
};
return () => {
eventsource.close();
};
}).pipe(operators_1.finalize(() => {
else {
subject.error(event);
}
};
return subject.asObservable().pipe(operators_1.finalize(() => {
eventsource.close();
eventsource.readyState = 2;
}));

@@ -84,0 +75,0 @@ }

{
"name": "@obelisk/client",
"version": "2.1.1",
"version": "2.1.2",
"description": "Typescript client to interact with Obelisk on a higher level than the regular ReST API calls.",

@@ -42,3 +42,3 @@ "keywords": [

"eventsource": "^1.0.7",
"rxjs": "6.x"
"rxjs": "^6.5.1"
},

@@ -45,0 +45,0 @@ "peerDependencies": {

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