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

@nats-io/nats-core

Package Overview
Dependencies
Maintainers
0
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nats-io/nats-core - npm Package Compare versions

Comparing version 3.0.0-27 to 3.0.0-28

2

lib/core.d.ts

@@ -90,4 +90,2 @@ /**

export declare class NatsError extends Error {
name: string;
message: string;
code: string;

@@ -94,0 +92,0 @@ permissionContext?: {

@@ -118,4 +118,2 @@ "use strict";

class NatsError extends Error {
name;
message;
// TODO: on major version this should change to a number/enum

@@ -122,0 +120,0 @@ code;

2

lib/internal_mod.d.ts

@@ -8,3 +8,3 @@ export { NatsConnectionImpl } from "./nats";

export { Connect, INFO, ProtocolHandler } from "./protocol";
export type { Backoff, Cancelable, Deferred, Delay, ErrorResult, Perf, Result, Timeout, ValueResult, } from "./util";
export type { Backoff, Deferred, Delay, ErrorResult, Perf, Result, Timeout, ValueResult, } from "./util";
export { backoff, collect, deadline, deferred, delay, extend, millis, nanos, render, SimpleMutex, timeout, } from "./util";

@@ -11,0 +11,0 @@ export { canonicalMIMEHeaderKey, headers, MsgHdrsImpl } from "./headers";

export { backoff, Bench, buildAuthenticator, canonicalMIMEHeaderKey, createInbox, credsAuthenticator, deadline, DebugEvents, deferred, delay, Empty, ErrorCode, Events, headers, JSONCodec, jwtAuthenticator, Match, Metric, millis, MsgHdrsImpl, nanos, NatsError, nkeyAuthenticator, nkeys, Nuid, nuid, RequestStrategy, StringCodec, syncIterator, tokenAuthenticator, usernamePasswordAuthenticator, wsconnect, } from "./internal_mod";
export type { ApiError, Auth, Authenticator, Backoff, BenchOpts, Cancelable, Codec, ConnectionOptions, Deferred, Delay, DispatchedFn, IngestionFilterFn, IngestionFilterFnResult, JwtAuth, Msg, MsgAdapter, MsgCallback, MsgHdrs, Nanos, NatsConnection, NKeyAuth, NoAuth, Payload, Perf, ProtocolFilterFn, Publisher, PublishOptions, QueuedIterator, RequestManyOptions, RequestOptions, ReviverFn, ServerInfo, ServersChanged, Stats, Status, Sub, SubOpts, Subscription, SubscriptionOptions, SyncIterator, Timeout, TlsOptions, TokenAuth, TypedCallback, TypedSubscriptionOptions, UserPass, } from "./internal_mod";
export type { ApiError, Auth, Authenticator, Backoff, BenchOpts, Codec, ConnectionOptions, Deferred, Delay, DispatchedFn, IngestionFilterFn, IngestionFilterFnResult, JwtAuth, Msg, MsgAdapter, MsgCallback, MsgHdrs, Nanos, NatsConnection, NKeyAuth, NoAuth, Payload, Perf, ProtocolFilterFn, Publisher, PublishOptions, QueuedIterator, RequestManyOptions, RequestOptions, ReviverFn, ServerInfo, ServersChanged, Stats, Status, Sub, SubOpts, Subscription, SubscriptionOptions, SyncIterator, Timeout, TlsOptions, TokenAuth, TypedCallback, TypedSubscriptionOptions, UserPass, } from "./internal_mod";

@@ -26,10 +26,7 @@ import type { Nanos } from "./core";

export declare function render(frame: Uint8Array): string;
export interface Cancelable {
export interface Timeout<T> extends Promise<T> {
cancel: () => void;
}
export interface Timeout<T> extends Promise<T>, Cancelable {
cancel: () => void;
}
export declare function timeout<T>(ms: number, asyncTraces?: boolean): Timeout<T>;
export interface Delay extends Promise<boolean>, Cancelable {
export interface Delay extends Promise<void> {
cancel: () => void;

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

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

const timer = setTimeout(() => {
resolve(true);
resolve();
}, ms);

@@ -85,3 +85,3 @@ const cancel = () => {

clearTimeout(timer);
resolve(false);
resolve();
}

@@ -88,0 +88,0 @@ };

@@ -1,1 +0,1 @@

export declare const version = "3.0.0-27";
export declare const version = "3.0.0-28";

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

// This file is generated - do not edit
exports.version = "3.0.0-27";
exports.version = "3.0.0-28";
//# sourceMappingURL=version.js.map

@@ -34,3 +34,2 @@ import type { ConnectionOptions, Deferred, NatsConnection, Server, Transport } from "./internal_mod";

closed(): Promise<void | Error>;
isDiscarded(): boolean;
discard(): void;

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

@@ -53,8 +53,3 @@ "use strict";

const connected = false;
const connLock = (0, internal_mod_1.deferred)();
// ws client doesn't support TLS setting
if (options.tls) {
connLock.reject(new internal_mod_1.NatsError("tls", internal_mod_1.ErrorCode.InvalidOption));
return connLock;
}
const ok = (0, internal_mod_1.deferred)();
this.options = options;

@@ -73,4 +68,4 @@ const u = server.src;

this.socket.onopen = () => {
if (this.isDiscarded()) {
return;
if (this.done) {
this._closed(new Error("aborted"));
}

@@ -80,3 +75,3 @@ // we don't do anything here...

this.socket.onmessage = (me) => {
if (this.isDiscarded()) {
if (this.done) {
return;

@@ -97,3 +92,3 @@ }

}
connLock.reject(new Error("unexpected response from server"));
ok.reject(new Error("unexpected response from server"));
return;

@@ -107,6 +102,6 @@ }

this.signal.resolve();
connLock.resolve();
ok.resolve();
}
catch (err) {
connLock.reject(err);
ok.reject(err);
return;

@@ -118,9 +113,4 @@ }

this.socket.onclose = (evt) => {
if (this.isDiscarded()) {
return;
}
this.socketClosed = true;
let reason;
if (this.done)
return;
if (!evt.wasClean) {

@@ -130,6 +120,11 @@ reason = new Error(evt.reason);

this._closed(reason);
this.socket.onopen = null;
this.socket.onmessage = null;
this.socket.onerror = null;
this.socket.onclose = null;
this.closedNotification.resolve(this.closeError);
};
// @ts-ignore: signature can be any
this.socket.onerror = (e) => {
if (this.isDiscarded()) {
if (this.done) {
return;

@@ -140,3 +135,3 @@ }

if (!connected) {
connLock.reject(err);
ok.reject(err);
}

@@ -147,3 +142,3 @@ else {

};
return connLock;
return ok;
}

@@ -153,10 +148,12 @@ disconnect() {

}
async _closed(err, internal = true) {
if (this.isDiscarded()) {
async _closed(err, _internal = true) {
if (this.done) {
try {
this.socket.close();
}
catch (_) {
// nothing
}
return;
}
if (!this.connected)
return;
if (this.done)
return;
this.closeError = err;

@@ -170,4 +167,3 @@ if (!err) {

try {
// 1002 endpoint error, 1000 is clean
this.socket.close(err ? 1002 : 1000, err ? err.message : undefined);
this.socket.close();
}

@@ -177,5 +173,3 @@ catch (_) {

}
if (internal) {
this.closedNotification.resolve(err);
}
return this.closedNotification;
}

@@ -190,3 +184,3 @@ get isClosed() {

while (true) {
if (this.isDiscarded()) {
if (this.done) {
return;

@@ -222,3 +216,3 @@ }

send(frame) {
if (this.isDiscarded()) {
if (this.done) {
return;

@@ -248,11 +242,2 @@ }

}
// check to see if we are discarded, as the connection
// may not have been closed, we attempt it here as well.
isDiscarded() {
if (this.done) {
this.discard();
return true;
}
return false;
}
// this is to allow a force discard on a connection

@@ -264,9 +249,3 @@ // if the connection fails during the handshake protocol.

discard() {
this.done = true;
try {
this.socket?.close();
}
catch (_err) {
// ignored
}
this.socket?.close();
}

@@ -329,2 +308,5 @@ }

factory: () => {
if (opts.tls) {
throw new internal_mod_1.NatsError("tls", internal_mod_1.ErrorCode.InvalidOption);
}
return new WsTransport();

@@ -331,0 +313,0 @@ },

{
"name": "@nats-io/nats-core",
"version": "3.0.0-27",
"version": "3.0.0-28",
"files": [

@@ -27,3 +27,5 @@ "lib/",

"doc": "npm run build && node_modules/.bin/typedoc --out ../docs/core && touch ../docs/core/.nojekyll",
"prepack": "npm run build"
"prepack": "npm run build",
"bump-qualifier": "npm version prerelease --no-commit-hooks --no-git-tag-version",
"bump-release": "npm version patch --no-commit-hooks --no-git-tag-version"
},

@@ -36,3 +38,3 @@ "keywords": [],

"dependencies": {
"@nats-io/nkeys": "1.2.0-4",
"@nats-io/nkeys": "1.2.0-7",
"@nats-io/nuid": "2.0.1-2"

@@ -39,0 +41,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