Socket
Socket
Sign inDemoInstall

@oada/client

Package Overview
Dependencies
Maintainers
8
Versions
73
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 4.3.2 to 4.4.0

2

dist/auto.d.ts

@@ -31,2 +31,2 @@ /**

userAgent: string;
}): Promise<HttpClient | WebSocketClient>;
}): Promise<WebSocketClient | HttpClient>;

@@ -25,3 +25,3 @@ /**

switch (url.protocol) {
case 'http2:':
case 'http2:': {
return Object.assign(url, {

@@ -31,3 +31,4 @@ port: Number(url.port) || 80,

});
case 'https:':
}
case 'https:': {
return Object.assign(url, {

@@ -37,3 +38,4 @@ port: Number(url.port) || 443,

});
case 'http:':
}
case 'http:': {
return Object.assign(url, {

@@ -43,4 +45,6 @@ port: Number(url.port) || 80,

});
default:
}
default: {
throw new Error(`Unsupported domain protocol: ${url.protocol}`);
}
}

@@ -72,10 +76,13 @@ }

// Prefer HTTP/2
case 'h2':
case 'h2': {
return new HttpClient(domain, token, { concurrency, userAgent });
}
// If no HTTP/2, use a WebSocket
case 'http/1.1':
case 'http/1.0':
case 'http/1.0': {
return new WebSocketClient(domain, { concurrency, userAgent });
default:
}
default: {
throw new Error(`Unsupported ALPN protocol: ${alpnProtocol}`);
}
}

@@ -82,0 +89,0 @@ }

@@ -69,5 +69,6 @@ /**

switch (connection) {
case 'auto':
case 'auto': {
throw new Error('Connection type "auto" is not supported');
case 'ws':
}
case 'ws': {
__classPrivateFieldSet(this, _OADAClient_connection, new WebSocketClient(__classPrivateFieldGet(this, _OADAClient_domain, "f"), {

@@ -78,3 +79,4 @@ concurrency: __classPrivateFieldGet(this, _OADAClient_concurrency, "f"),

break;
case 'http':
}
case 'http': {
__classPrivateFieldSet(this, _OADAClient_connection, new HttpClient(__classPrivateFieldGet(this, _OADAClient_domain, "f"), __classPrivateFieldGet(this, _OADAClient_token, "f"), {

@@ -85,5 +87,7 @@ concurrency: __classPrivateFieldGet(this, _OADAClient_concurrency, "f"),

break;
default:
}
default: {
// Otherwise, they gave us a WebSocketClient to use
__classPrivateFieldSet(this, _OADAClient_connection, connection, "f");
}
}

@@ -90,0 +94,0 @@ }

@@ -82,4 +82,5 @@ /**

switch (`${error.status ?? cError?.code}`) {
case '429':
case '429': {
return await handleRatelimit(error, request, ...rest);
}
// Some servers use 503 for rate limit...

@@ -94,4 +95,5 @@ case '503': {

}
case 'ECONNRESET':
case 'ECONNRESET': {
return await handleReset(error, request, ...rest);
}
default:

@@ -98,0 +100,0 @@ // Do nothing

@@ -17,2 +17,9 @@ /**

*/
import fetch from 'cross-fetch';
export * from 'cross-fetch';
export default fetch;
declare const AbortController: {
new (): AbortController;
prototype: AbortController;
};
export { AbortController };

@@ -17,3 +17,9 @@ /**

*/
import fetch from 'cross-fetch';
export * from 'cross-fetch';
// eslint-disable-next-line unicorn/prefer-export-from -- HACK: for vite
export default fetch; // HACK: a`
// eslint-disable-next-line @typescript-eslint/naming-convention -- HACK: for vite
const { AbortController } = global;
export { AbortController };
//# sourceMappingURL=fetch-browser.js.map

@@ -27,2 +27,3 @@ /**

export { Headers } from 'cross-fetch';
export * from 'fetch-h2';
export { fetch as default } from 'fetch-h2';

@@ -32,3 +32,4 @@ /**

// Cross-fetch has fetch as default export
export * from 'fetch-h2';
export { fetch as default } from 'fetch-h2';
//# sourceMappingURL=fetch.js.map

@@ -20,3 +20,2 @@ /**

import { Buffer } from 'buffer';
import { AbortController } from 'fetch-h2';
import EventEmitter from 'eventemitter3';

@@ -30,3 +29,3 @@ import PQueue from 'p-queue';

// eslint-disable-next-line node/no-extraneous-import -- hack for skypack?
import fetch, { context } from '@oada/client/dist/fetch.js';
import fetch, { AbortController, context } from '@oada/client/dist/fetch.js';
import { WebSocketClient } from './websocket.js';

@@ -126,2 +125,3 @@ import { handleErrors } from './errors.js';

// Check for WATCH/UNWATCH
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
if (request.watch || request.method === 'unwatch') {

@@ -213,3 +213,3 @@ trace('WATCH/UNWATCH not currently supported for http(2), falling-back to ws');

// Happens when the HTTP/2 session is killed
case 'ERR_HTTP2_INVALID_SESSION':
case 'ERR_HTTP2_INVALID_SESSION': {
error('HTTP/2 session was killed, reconnecting');

@@ -220,4 +220,6 @@ if ('disconnect' in __classPrivateFieldGet(this, _HttpClient_context, "f")) {

return __classPrivateFieldGet(this, _HttpClient_instances, "m", _HttpClient_doRequest).call(this, request, timeout);
default:
}
default: {
throw cError;
}
}

@@ -224,0 +226,0 @@ }

@@ -18,3 +18,4 @@ /**

/// <reference path="../lib/types.d.ts" />
import { Config, OADAClient } from './client.js';
import type { Config } from './client.js';
import { OADAClient } from './client.js';
import type ChangeArray from '@oada/types/oada/change/v2.js';

@@ -28,3 +29,4 @@ /** Create a new instance of OADAClient */

}): Promise<OADAClient>;
export { OADAClient, Config, GETRequest, PUTRequest, HEADRequest, WatchRequest, ConnectionRequest, ConnectionResponse, ConnectionChange, Connection, } from './client.js';
export type { Config, GETRequest, PUTRequest, HEADRequest, WatchRequest, ConnectionRequest, ConnectionResponse, ConnectionChange, Connection, } from './client.js';
export { OADAClient } from './client.js';
export declare type JsonPrimitive = string | number | boolean | null;

@@ -31,0 +33,0 @@ export declare type JsonArray = Json[];

@@ -19,4 +19,4 @@ /**

/// <reference path="types.d.ts" />
import { autoConnection, parseDomain } from './auto.js';
import { OADAClient } from './client.js';
import { autoConnection, parseDomain } from './auto.js';
/** Create a new instance of OADAClient */

@@ -46,3 +46,3 @@ export function createInstance(config) {

}
export { OADAClient, } from './client.js';
export { OADAClient } from './client.js';
//# sourceMappingURL=index.js.map

@@ -26,4 +26,4 @@ /**

import { setTimeout } from 'isomorphic-timers-promises';
import { assert as assertOADASocketRequest, } from '@oada/types/oada/websockets/request.js';
import { assert as assertOADAChangeV2 } from '@oada/types/oada/change/v2.js';
import { assert as assertOADASocketRequest } from '@oada/types/oada/websockets/request.js';
import { is as isOADASocketChange } from '@oada/types/oada/websockets/change.js';

@@ -30,0 +30,0 @@ import { is as isOADASocketResponse } from '@oada/types/oada/websockets/response.js';

@@ -29,3 +29,3 @@ /**

switch (url.protocol) {
case 'http2:':
case 'http2:': {
return Object.assign(url, {

@@ -35,4 +35,5 @@ port: Number(url.port) || 80,

});
}
case 'https:':
case 'https:': {
return Object.assign(url, {

@@ -42,4 +43,5 @@ port: Number(url.port) || 443,

});
}
case 'http:':
case 'http:': {
return Object.assign(url, {

@@ -49,5 +51,7 @@ port: Number(url.port) || 80,

});
}
default:
default: {
throw new Error(`Unsupported domain protocol: ${url.protocol}`);
}
}

@@ -91,11 +95,15 @@ }

// Prefer HTTP/2
case 'h2':
case 'h2': {
return new HttpClient(domain, token, { concurrency, userAgent });
}
// If no HTTP/2, use a WebSocket
case 'http/1.1':
case 'http/1.0':
case 'http/1.0': {
return new WebSocketClient(domain, { concurrency, userAgent });
default:
}
default: {
throw new Error(`Unsupported ALPN protocol: ${alpnProtocol}`);
}
}

@@ -102,0 +110,0 @@ } catch (cError: unknown) {

@@ -279,5 +279,7 @@ /**

switch (connection) {
case 'auto':
case 'auto': {
throw new Error('Connection type "auto" is not supported');
case 'ws':
}
case 'ws': {
this.#connection = new WebSocketClient(this.#domain, {

@@ -288,3 +290,5 @@ concurrency: this.#concurrency,

break;
case 'http':
}
case 'http': {
this.#connection = new HttpClient(this.#domain, this.#token, {

@@ -295,5 +299,8 @@ concurrency: this.#concurrency,

break;
default:
}
default: {
// Otherwise, they gave us a WebSocketClient to use
this.#connection = connection;
}
}

@@ -300,0 +307,0 @@ }

@@ -106,4 +106,6 @@ /**

switch (`${error.status ?? cError?.code}`) {
case '429':
case '429': {
return await handleRatelimit(error, request, ...rest);
}
// Some servers use 503 for rate limit...

@@ -120,4 +122,5 @@ case '503': {

case 'ECONNRESET':
case 'ECONNRESET': {
return await handleReset(error, request, ...rest);
}

@@ -124,0 +127,0 @@ default:

@@ -18,2 +18,11 @@ /**

import fetch from 'cross-fetch';
export * from 'cross-fetch';
// eslint-disable-next-line unicorn/prefer-export-from -- HACK: for vite
export default fetch; // HACK: a`
// eslint-disable-next-line @typescript-eslint/naming-convention -- HACK: for vite
const { AbortController } = global;
export { AbortController };

@@ -40,3 +40,4 @@ /**

// Cross-fetch has fetch as default export
export * from 'fetch-h2';
export { fetch as default } from 'fetch-h2';

@@ -20,6 +20,5 @@ /**

import { AbortController, Method } from 'fetch-h2';
import type { Method, Response } from 'fetch-h2';
import EventEmitter from 'eventemitter3';
import PQueue from 'p-queue';
import type { Response } from 'fetch-h2';
import debug from 'debug';

@@ -39,3 +38,3 @@ import { fromString } from 'media-type';

// eslint-disable-next-line node/no-extraneous-import -- hack for skypack?
import fetch, { context } from '@oada/client/dist/fetch.js';
import fetch, { AbortController, context } from '@oada/client/dist/fetch.js';
import type { Json } from './index.js';

@@ -166,2 +165,3 @@ import { WebSocketClient } from './websocket.js';

// Check for WATCH/UNWATCH
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
if (request.watch || request.method === 'unwatch') {

@@ -277,3 +277,3 @@ trace(

// Happens when the HTTP/2 session is killed
case 'ERR_HTTP2_INVALID_SESSION':
case 'ERR_HTTP2_INVALID_SESSION': {
error('HTTP/2 session was killed, reconnecting');

@@ -285,5 +285,7 @@ if ('disconnect' in this.#context) {

return this.#doRequest(request, timeout);
}
default:
default: {
throw cError as Error;
}
}

@@ -290,0 +292,0 @@ }

@@ -21,4 +21,5 @@ /**

import { Config, OADAClient } from './client.js';
import { autoConnection, parseDomain } from './auto.js';
import type { Config } from './client.js';
import { OADAClient } from './client.js';

@@ -60,4 +61,3 @@ import type ChangeArray from '@oada/types/oada/change/v2.js';

export {
OADAClient,
export type {
Config,

@@ -74,2 +74,3 @@ GETRequest,

} from './client.js';
export { OADAClient } from './client.js';

@@ -76,0 +77,0 @@ // eslint-disable-next-line @typescript-eslint/ban-types

@@ -35,3 +35,3 @@ /**

): E {
return isArray(itemOrArray) ? itemOrArray : ([itemOrArray] as E);
return isArray<E>(itemOrArray) ? itemOrArray : ([itemOrArray] as E);
}

@@ -38,0 +38,0 @@

@@ -26,6 +26,5 @@ /**

import WebSocketRequest, {
assert as assertOADASocketRequest,
} from '@oada/types/oada/websockets/request.js';
import type WebSocketRequest from '@oada/types/oada/websockets/request.js';
import { assert as assertOADAChangeV2 } from '@oada/types/oada/change/v2.js';
import { assert as assertOADASocketRequest } from '@oada/types/oada/websockets/request.js';
import { is as isOADASocketChange } from '@oada/types/oada/websockets/change.js';

@@ -32,0 +31,0 @@ import { is as isOADASocketResponse } from '@oada/types/oada/websockets/response.js';

{
"name": "@oada/client",
"version": "4.3.2",
"version": "4.4.0",
"description": "A lightweight client tool to interact with an OADA-compliant server",

@@ -86,3 +86,3 @@ "repository": "https://github.com/OADA/client",

"dependencies": {
"@oada/types": "^3.2.1",
"@oada/types": "^3.3.0",
"abort-controller": "^3.0.0",

@@ -98,3 +98,3 @@ "buffer": "^6.0.3",

"fetch-h2": "^3.0.2",
"file-type": "^17.1.6",
"file-type": "^18.0.0",
"isomorphic-timers-promises": "^1.0.1",

@@ -106,6 +106,6 @@ "isomorphic-ws": "^5.0.0",

"resolve-alpn": "^1.2.1",
"supports-color": "^9.2.2",
"supports-color": "^9.2.3",
"tslib": "^2.4.0",
"utf-8-validate": "^5.0.9",
"ws": "^8.8.1",
"ws": "^8.9.0",
"xksuid": "^0.0.3"

@@ -117,15 +117,15 @@ },

"@types/debug": "^4.1.7",
"@types/node": "^16.11.56",
"@types/node": "^16.11.65",
"@types/ws": "^8.5.3",
"@typescript-eslint/eslint-plugin": "^5.34.0",
"@typescript-eslint/parser": "^5.34.0",
"@yarnpkg/sdks": "3.0.0-rc.15",
"ava": "4.3.1",
"axios": "^0.27.2",
"@typescript-eslint/eslint-plugin": "^5.40.0",
"@typescript-eslint/parser": "^5.40.0",
"@yarnpkg/sdks": "3.0.0-rc.25",
"ava": "4.3.3",
"axios": "^1.1.2",
"c8": "^7.12.0",
"dotenv": "^16.0.1",
"eslint": "^8.22.0",
"dotenv": "^16.0.3",
"eslint": "^8.25.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-xo": "^0.41.0",
"eslint-config-xo-typescript": "^0.52.0",
"eslint-config-xo": "^0.42.0",
"eslint-config-xo-typescript": "^0.53.0",
"eslint-formatter-pretty": "^4.1.0",

@@ -135,5 +135,6 @@ "eslint-import-resolver-node": "^0.3.6",

"eslint-plugin-ava": "^13.2.0",
"eslint-plugin-escompat": "^3.3.3",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-filenames": "^1.3.2",
"eslint-plugin-github": "^4.3.7",
"eslint-plugin-github": "^4.4.0",
"eslint-plugin-i18n-text": "^1.0.1",

@@ -148,11 +149,11 @@ "eslint-plugin-import": "^2.26.0",

"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-promise": "^6.1.0",
"eslint-plugin-regexp": "^1.9.0",
"eslint-plugin-security": "^1.5.0",
"eslint-plugin-sonarjs": "^0.15.0",
"eslint-plugin-unicorn": "^43.0.2",
"eslint-plugin-sonarjs": "^0.16.0",
"eslint-plugin-unicorn": "^44.0.2",
"prettier": "^2.7.1",
"typescript": "4.7.4"
"typescript": "4.8.2"
},
"packageManager": "yarn@3.2.2",
"packageManager": "yarn@3.2.4",
"volta": {

@@ -159,0 +160,0 @@ "node": "16.16.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

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

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