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

@oada/client

Package Overview
Dependencies
Maintainers
8
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oada/client - npm Package Compare versions

Comparing version 2.1.1 to 2.1.2-beta.0

4

dist/client.d.ts
/// <reference types="node" />
import { EventEmitter } from 'events';
import { EventEmitter } from "events";
import { Json, Change } from ".";

@@ -34,3 +34,3 @@ export interface ConnectionRequest {

concurrency?: number;
connection?: 'ws' | 'http' | Connection;
connection?: "ws" | "http" | Connection;
}

@@ -37,0 +37,0 @@ export declare type Response = ConnectionResponse;

@@ -30,6 +30,6 @@ "use strict";

this._renewedReqIdMap = new Map();
if (!config.connection || config.connection === 'ws') {
if (!config.connection || config.connection === "ws") {
this._ws = new websocket_1.WebSocketClient(this._domain, this._concurrency);
}
else if (config.connection === 'http') {
else if (config.connection === "http") {
this._ws = new http_1.HttpClient(this._domain, this._token, this._concurrency);

@@ -36,0 +36,0 @@ }

/// <reference types="node" />
import { EventEmitter } from "events";
import { ConnectionRequest, ConnectionResponse, ConnectionChange, Connection } from './client';
import { ConnectionRequest, ConnectionResponse, ConnectionChange, Connection } from "./client";
export declare class HttpClient extends EventEmitter implements Connection {

@@ -5,0 +5,0 @@ private _domain;

@@ -24,3 +24,3 @@ "use strict";

this._domain = domain.match(/^http/) ? domain : `https://${domain}`;
this._domain = this._domain.replace(/\/$/, '');
this._domain = this._domain.replace(/\/$/, "");
this._token = token;

@@ -30,6 +30,6 @@ this._status = ConnectionStatus.Connecting;

this.initialConnection = cross_fetch_1.default(`${this._domain}/bookmarks`, {
method: 'HEAD',
headers: { 'authorization': `Bearer ${this._token}` }
}).then(result => {
trace('Initial HEAD returned status: ', result.status);
method: "HEAD",
headers: { authorization: `Bearer ${this._token}` },
}).then((result) => {
trace("Initial HEAD returned status: ", result.status);
if (result.status < 400) {

@@ -43,3 +43,3 @@ trace('Initial HEAD succeeded, emitting "open"');

this._status = ConnectionStatus.Disconnected;
this.emit('close');
this.emit("close");
}

@@ -54,3 +54,3 @@ });

this._status = ConnectionStatus.Disconnected;
this.emit('close');
this.emit("close");
}

@@ -64,16 +64,16 @@ isConnected() {

request(req, callback, timeout) {
trace('Starting http request: ', req);
if (req.method === 'watch' || req.method === 'unwatch') {
throw new Error('HTTP (i.e. non-WebSocket) Client cannot do watches');
trace("Starting http request: ", req);
if (req.method === "watch" || req.method === "unwatch") {
throw new Error("HTTP (i.e. non-WebSocket) Client cannot do watches");
}
if (callback) {
throw new Error('HTTP (i.e. non-WebSocket) Client cannot handle a watch callback');
throw new Error("HTTP (i.e. non-WebSocket) Client cannot handle a watch callback");
}
if (!req.requestId)
req.requestId = ksuid_1.default.randomSync().string;
trace('Adding http request w/ id ', req.requestId, ' to the queue');
trace("Adding http request w/ id ", req.requestId, " to the queue");
return this._q.add(() => this.doRequest(req, timeout));
}
async doRequest(req, timeout) {
trace('Pulled request ', req.requestId, ' from queue, starting on it');
trace("Pulled request ", req.requestId, " from queue, starting on it");
request_1.assert(req);

@@ -83,3 +83,3 @@ trace(`Req looks like a socket request, awaiting race between timeout and fetch to ${this._domain}${req.path}`);

if (timeout) {
setTimeout(() => timedout = true, timeout);
setTimeout(() => (timedout = true), timeout);
}

@@ -90,5 +90,5 @@ const result = await cross_fetch_1.default(`${this._domain}${req.path}`, {

headers: req.headers,
}).then(res => {
}).then((res) => {
if (timedout)
throw new Error('Request timeout');
throw new Error("Request timeout");
return res;

@@ -103,7 +103,7 @@ });

const headers = {};
result.headers.forEach((value, key) => headers[key] = value);
const length = +(result.headers.get('content-length') || 0);
result.headers.forEach((value, key) => (headers[key] = value));
const length = +(result.headers.get("content-length") || 0);
let data = null;
if (req.method.toUpperCase() !== 'HEAD') {
const isJSON = (result.headers.get('content-type') || '').match(/json/);
if (req.method.toUpperCase() !== "HEAD") {
const isJSON = (result.headers.get("content-type") || "").match(/json/);
if (!isJSON) {

@@ -122,3 +122,3 @@ data = await result.arrayBuffer();

headers,
data
data,
};

@@ -125,0 +125,0 @@ }

import { OADAClient, Config } from "./client";
export declare function createInstance(config: Config): OADAClient;
export declare function connect(config: Config): Promise<OADAClient>;
export { OADAClient, Config, GETRequest, PUTRequest, HEADRequest, WatchRequest, ConnectionRequest, ConnectionResponse, ConnectionChange, Connection } from "./client";
export { OADAClient, Config, GETRequest, PUTRequest, HEADRequest, WatchRequest, ConnectionRequest, ConnectionResponse, ConnectionChange, Connection, } from "./client";
export declare type Json = null | boolean | number | string | Json[] | {

@@ -6,0 +6,0 @@ [prop: string]: Json;

@@ -27,3 +27,3 @@ "use strict";

else {
throw new Error("Specified path /" + path.join('/') + " does not exist in the tree.");
throw new Error("Specified path /" + path.join("/") + " does not exist in the tree.");
}

@@ -45,3 +45,3 @@ }, tree);

else {
throw new Error("Specified path /" + path.join('/') + " does not exist in the tree.");
throw new Error("Specified path /" + path.join("/") + " does not exist in the tree.");
}

@@ -48,0 +48,0 @@ }, tree);

import { WebSocketClient } from "./websocket";
export declare class Watchdog {
private _wsClient;
private _callback;
private _pingInterval;
private _timeoutTimerID;
private _pingTimerID;
constructor(wsClient: WebSocketClient, callback: () => void, pingInterval: number);
resetTimer(): void;
private _sendPing;
private _wsClient;
private _callback;
private _pingInterval;
private _timeoutTimerID;
private _pingTimerID;
constructor(
wsClient: WebSocketClient,
callback: () => void,
pingInterval: number
);
resetTimer(): void;
private _sendPing;
}
/// <reference types="node" />
import { EventEmitter } from "events";
import { ConnectionRequest, ConnectionResponse, ConnectionChange, Connection } from './client';
import { ConnectionRequest, ConnectionResponse, ConnectionChange, Connection } from "./client";
export declare class WebSocketClient extends EventEmitter implements Connection {

@@ -5,0 +5,0 @@ private _ws;

{
"name": "@oada/client",
"version": "2.1.1",
"version": "2.1.2-beta.0",
"description": "A lightweight client tool to interact with an OADA-compliant server",
"repository": "https://github.com/OADA/client",
"main": "dist/index.js",

@@ -13,2 +14,3 @@ "types": "dist/index.d.ts",

"build": "tsc",
"prettier": "prettier --write '{lib,test}/**/*.ts'",
"prepare": "npm run build",

@@ -21,3 +23,3 @@ "prestart": "npm run build",

"dependencies": {
"@oada/types": "^1.0.6",
"@oada/types": "^1.2.0-beta.18",
"cross-fetch": "^3.0.6",

@@ -40,6 +42,7 @@ "debug": "^4.1.1",

"@types/ws": "^7.2.4",
"axios": "^0.20.0",
"axios": "^0.21.1",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"mocha": "^7.1.1",
"prettier": "^2.2.1",
"ts-node": "^8.8.2",

@@ -46,0 +49,0 @@ "typescript": "^3.8.3"

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

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