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-32 to 3.0.0-34

2

lib/core.js

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

if (v === "*" || v === ">") {
throw new errors_1.errors.InvalidArgumentError(errors_1.InvalidArgumentError.format("prefix", `cannot have wildcards ('${prefix}')`));
throw errors_1.InvalidArgumentError.format("prefix", `cannot have wildcards ('${prefix}')`);
}

@@ -95,0 +95,0 @@ });

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

constructor(message: string, options?: ErrorOptions);
static format(name: string, message: string): string;
static formatMultiple(names: string[], message: string): string;
static format(property: string | string[], message: string, options?: ErrorOptions): InvalidArgumentError;
}

@@ -105,2 +104,3 @@ /**

constructor(message?: string, options?: ErrorOptions);
isNoResponders(): boolean;
}

@@ -107,0 +107,0 @@ /**

@@ -37,9 +37,15 @@ "use strict";

}
static format(name, message) {
return `'${name}' ${message}`;
static format(property, message, options) {
if (Array.isArray(message) && message.length > 1) {
message = message[0];
}
if (Array.isArray(property)) {
property = property.map((n) => `'${n}'`);
property = property.join(",");
}
else {
property = `'${property}'`;
}
return new InvalidArgumentError(`${property} ${message}`, options);
}
static formatMultiple(names, message) {
names = names.map((n) => `'${n}'`);
return `${names.join(",")} ${message}`;
}
}

@@ -185,2 +191,5 @@ exports.InvalidArgumentError = InvalidArgumentError;

}
isNoResponders() {
return this.cause instanceof NoRespondersError;
}
}

@@ -187,0 +196,0 @@ exports.RequestError = RequestError;

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

if (c === colon || c < start || c > end) {
throw new errors_1.errors.InvalidArgumentError(errors_1.errors.InvalidArgumentError.format("header", `'${k[i]}' is not a valid character in a header name`));
throw errors_1.InvalidArgumentError.format("header", `'${k[i]}' is not a valid character in a header name`);
}

@@ -67,3 +67,3 @@ if (upper && a <= c && c <= z) {

if ((code === 0 && description !== "") || (code > 0 && description === "")) {
throw new errors_1.errors.InvalidArgumentError(errors_1.errors.InvalidArgumentError.format("description", "is required"));
throw errors_1.InvalidArgumentError.format("description", "is required");
}

@@ -161,3 +161,3 @@ return new MsgHdrsImpl(code, description);

if (inv.test(k)) {
throw new errors_1.errors.InvalidArgumentError(errors_1.errors.InvalidArgumentError.format("header", "values cannot contain \\r or \\n"));
throw errors_1.InvalidArgumentError.format("header", "values cannot contain \\r or \\n");
}

@@ -164,0 +164,0 @@ return k.trim();

@@ -40,2 +40,2 @@ export { NatsConnectionImpl } from "./nats";

export { wsconnect, wsUrlParseFn } from "./ws_transport";
export { errors } from "./errors";
export { AuthorizationError, ClosedConnectionError, ConnectionError, DrainingConnectionError, errors, InvalidArgumentError, InvalidOperationError, InvalidSubjectError, NoRespondersError, PermissionViolationError, ProtocolError, RequestError, TimeoutError, UserAuthenticationExpiredError, } from "./errors";

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

exports.TE = exports.TD = exports.Metric = exports.Bench = exports.writeAll = exports.readAll = exports.MAX_SIZE = exports.DenoBuffer = exports.State = exports.Parser = exports.Kind = exports.QueuedIteratorImpl = exports.usernamePasswordAuthenticator = exports.tokenAuthenticator = exports.nkeyAuthenticator = exports.jwtAuthenticator = exports.credsAuthenticator = exports.RequestOne = exports.parseOptions = exports.defaultOptions = exports.DEFAULT_MAX_RECONNECT_ATTEMPTS = exports.checkUnsupportedOption = exports.checkOptions = exports.buildAuthenticator = exports.DataBuffer = exports.MuxSubscription = exports.Heartbeat = exports.MsgHdrsImpl = exports.headers = exports.canonicalMIMEHeaderKey = exports.timeout = exports.SimpleMutex = exports.render = exports.nanos = exports.millis = exports.extend = exports.delay = exports.deferred = exports.deadline = exports.collect = exports.backoff = exports.ProtocolHandler = exports.INFO = exports.Connect = exports.setTransportFactory = exports.getResolveFn = exports.MsgImpl = exports.nuid = exports.Nuid = exports.NatsConnectionImpl = void 0;
exports.errors = exports.wsUrlParseFn = exports.wsconnect = exports.SHA256 = exports.Base64UrlPaddedCodec = exports.Base64UrlCodec = exports.Base64Codec = exports.Servers = exports.isIPV4OrHostname = exports.IdleHeartbeatMonitor = exports.Subscriptions = exports.SubscriptionImpl = exports.syncIterator = exports.RequestStrategy = exports.Match = exports.Events = exports.DebugEvents = exports.createInbox = exports.protoLen = exports.extractProtocolMessage = exports.Empty = exports.parseSemVer = exports.Features = exports.Feature = exports.compare = exports.parseIP = exports.isIP = exports.ipV4 = void 0;
exports.UserAuthenticationExpiredError = exports.TimeoutError = exports.RequestError = exports.ProtocolError = exports.PermissionViolationError = exports.NoRespondersError = exports.InvalidSubjectError = exports.InvalidOperationError = exports.InvalidArgumentError = exports.errors = exports.DrainingConnectionError = exports.ConnectionError = exports.ClosedConnectionError = exports.AuthorizationError = exports.wsUrlParseFn = exports.wsconnect = exports.SHA256 = exports.Base64UrlPaddedCodec = exports.Base64UrlCodec = exports.Base64Codec = exports.Servers = exports.isIPV4OrHostname = exports.IdleHeartbeatMonitor = exports.Subscriptions = exports.SubscriptionImpl = exports.syncIterator = exports.RequestStrategy = exports.Match = exports.Events = exports.DebugEvents = exports.createInbox = exports.protoLen = exports.extractProtocolMessage = exports.Empty = exports.parseSemVer = exports.Features = exports.Feature = exports.compare = exports.parseIP = exports.isIP = exports.ipV4 = void 0;
var nats_1 = require("./nats");

@@ -142,3 +142,16 @@ Object.defineProperty(exports, "NatsConnectionImpl", { enumerable: true, get: function () { return nats_1.NatsConnectionImpl; } });

var errors_1 = require("./errors");
Object.defineProperty(exports, "AuthorizationError", { enumerable: true, get: function () { return errors_1.AuthorizationError; } });
Object.defineProperty(exports, "ClosedConnectionError", { enumerable: true, get: function () { return errors_1.ClosedConnectionError; } });
Object.defineProperty(exports, "ConnectionError", { enumerable: true, get: function () { return errors_1.ConnectionError; } });
Object.defineProperty(exports, "DrainingConnectionError", { enumerable: true, get: function () { return errors_1.DrainingConnectionError; } });
Object.defineProperty(exports, "errors", { enumerable: true, get: function () { return errors_1.errors; } });
Object.defineProperty(exports, "InvalidArgumentError", { enumerable: true, get: function () { return errors_1.InvalidArgumentError; } });
Object.defineProperty(exports, "InvalidOperationError", { enumerable: true, get: function () { return errors_1.InvalidOperationError; } });
Object.defineProperty(exports, "InvalidSubjectError", { enumerable: true, get: function () { return errors_1.InvalidSubjectError; } });
Object.defineProperty(exports, "NoRespondersError", { enumerable: true, get: function () { return errors_1.NoRespondersError; } });
Object.defineProperty(exports, "PermissionViolationError", { enumerable: true, get: function () { return errors_1.PermissionViolationError; } });
Object.defineProperty(exports, "ProtocolError", { enumerable: true, get: function () { return errors_1.ProtocolError; } });
Object.defineProperty(exports, "RequestError", { enumerable: true, get: function () { return errors_1.RequestError; } });
Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return errors_1.TimeoutError; } });
Object.defineProperty(exports, "UserAuthenticationExpiredError", { enumerable: true, get: function () { return errors_1.UserAuthenticationExpiredError; } });
//# sourceMappingURL=internal_mod.js.map

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

export { backoff, Bench, buildAuthenticator, canonicalMIMEHeaderKey, createInbox, credsAuthenticator, deadline, DebugEvents, deferred, delay, Empty, errors, Events, headers, jwtAuthenticator, Match, Metric, millis, MsgHdrsImpl, nanos, nkeyAuthenticator, nkeys, Nuid, nuid, RequestStrategy, syncIterator, tokenAuthenticator, usernamePasswordAuthenticator, wsconnect, } from "./internal_mod";
export { AuthorizationError, backoff, Bench, buildAuthenticator, canonicalMIMEHeaderKey, ClosedConnectionError, ConnectionError, createInbox, credsAuthenticator, deadline, DebugEvents, deferred, delay, DrainingConnectionError, Empty, errors, Events, headers, InvalidArgumentError, InvalidOperationError, InvalidSubjectError, jwtAuthenticator, Match, Metric, millis, MsgHdrsImpl, nanos, nkeyAuthenticator, nkeys, NoRespondersError, Nuid, nuid, PermissionViolationError, ProtocolError, RequestError, RequestStrategy, syncIterator, TimeoutError, tokenAuthenticator, UserAuthenticationExpiredError, usernamePasswordAuthenticator, wsconnect, } from "./internal_mod";
export type { Auth, Authenticator, Backoff, BenchOpts, Codec, ConnectionOptions, Deferred, Delay, JwtAuth, Msg, MsgCallback, MsgHdrs, Nanos, NatsConnection, NKeyAuth, NoAuth, Payload, Perf, Publisher, PublishOptions, QueuedIterator, RequestManyOptions, RequestOptions, ReviverFn, ServerInfo, ServersChanged, Stats, Status, SubOpts, Subscription, SubscriptionOptions, SyncIterator, Timeout, TlsOptions, TokenAuth, UserPass, } from "./internal_mod";

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.wsconnect = exports.usernamePasswordAuthenticator = exports.tokenAuthenticator = exports.syncIterator = exports.RequestStrategy = exports.nuid = exports.Nuid = exports.nkeys = exports.nkeyAuthenticator = exports.nanos = exports.MsgHdrsImpl = exports.millis = exports.Metric = exports.Match = exports.jwtAuthenticator = exports.headers = exports.Events = exports.errors = exports.Empty = exports.delay = exports.deferred = exports.DebugEvents = exports.deadline = exports.credsAuthenticator = exports.createInbox = exports.canonicalMIMEHeaderKey = exports.buildAuthenticator = exports.Bench = exports.backoff = void 0;
exports.wsconnect = exports.usernamePasswordAuthenticator = exports.UserAuthenticationExpiredError = exports.tokenAuthenticator = exports.TimeoutError = exports.syncIterator = exports.RequestStrategy = exports.RequestError = exports.ProtocolError = exports.PermissionViolationError = exports.nuid = exports.Nuid = exports.NoRespondersError = exports.nkeys = exports.nkeyAuthenticator = exports.nanos = exports.MsgHdrsImpl = exports.millis = exports.Metric = exports.Match = exports.jwtAuthenticator = exports.InvalidSubjectError = exports.InvalidOperationError = exports.InvalidArgumentError = exports.headers = exports.Events = exports.errors = exports.Empty = exports.DrainingConnectionError = exports.delay = exports.deferred = exports.DebugEvents = exports.deadline = exports.credsAuthenticator = exports.createInbox = exports.ConnectionError = exports.ClosedConnectionError = exports.canonicalMIMEHeaderKey = exports.buildAuthenticator = exports.Bench = exports.backoff = exports.AuthorizationError = void 0;
var internal_mod_1 = require("./internal_mod");
Object.defineProperty(exports, "AuthorizationError", { enumerable: true, get: function () { return internal_mod_1.AuthorizationError; } });
Object.defineProperty(exports, "backoff", { enumerable: true, get: function () { return internal_mod_1.backoff; } });

@@ -24,2 +25,4 @@ Object.defineProperty(exports, "Bench", { enumerable: true, get: function () { return internal_mod_1.Bench; } });

Object.defineProperty(exports, "canonicalMIMEHeaderKey", { enumerable: true, get: function () { return internal_mod_1.canonicalMIMEHeaderKey; } });
Object.defineProperty(exports, "ClosedConnectionError", { enumerable: true, get: function () { return internal_mod_1.ClosedConnectionError; } });
Object.defineProperty(exports, "ConnectionError", { enumerable: true, get: function () { return internal_mod_1.ConnectionError; } });
Object.defineProperty(exports, "createInbox", { enumerable: true, get: function () { return internal_mod_1.createInbox; } });

@@ -31,2 +34,3 @@ Object.defineProperty(exports, "credsAuthenticator", { enumerable: true, get: function () { return internal_mod_1.credsAuthenticator; } });

Object.defineProperty(exports, "delay", { enumerable: true, get: function () { return internal_mod_1.delay; } });
Object.defineProperty(exports, "DrainingConnectionError", { enumerable: true, get: function () { return internal_mod_1.DrainingConnectionError; } });
Object.defineProperty(exports, "Empty", { enumerable: true, get: function () { return internal_mod_1.Empty; } });

@@ -36,2 +40,5 @@ Object.defineProperty(exports, "errors", { enumerable: true, get: function () { return internal_mod_1.errors; } });

Object.defineProperty(exports, "headers", { enumerable: true, get: function () { return internal_mod_1.headers; } });
Object.defineProperty(exports, "InvalidArgumentError", { enumerable: true, get: function () { return internal_mod_1.InvalidArgumentError; } });
Object.defineProperty(exports, "InvalidOperationError", { enumerable: true, get: function () { return internal_mod_1.InvalidOperationError; } });
Object.defineProperty(exports, "InvalidSubjectError", { enumerable: true, get: function () { return internal_mod_1.InvalidSubjectError; } });
Object.defineProperty(exports, "jwtAuthenticator", { enumerable: true, get: function () { return internal_mod_1.jwtAuthenticator; } });

@@ -45,9 +52,15 @@ Object.defineProperty(exports, "Match", { enumerable: true, get: function () { return internal_mod_1.Match; } });

Object.defineProperty(exports, "nkeys", { enumerable: true, get: function () { return internal_mod_1.nkeys; } });
Object.defineProperty(exports, "NoRespondersError", { enumerable: true, get: function () { return internal_mod_1.NoRespondersError; } });
Object.defineProperty(exports, "Nuid", { enumerable: true, get: function () { return internal_mod_1.Nuid; } });
Object.defineProperty(exports, "nuid", { enumerable: true, get: function () { return internal_mod_1.nuid; } });
Object.defineProperty(exports, "PermissionViolationError", { enumerable: true, get: function () { return internal_mod_1.PermissionViolationError; } });
Object.defineProperty(exports, "ProtocolError", { enumerable: true, get: function () { return internal_mod_1.ProtocolError; } });
Object.defineProperty(exports, "RequestError", { enumerable: true, get: function () { return internal_mod_1.RequestError; } });
Object.defineProperty(exports, "RequestStrategy", { enumerable: true, get: function () { return internal_mod_1.RequestStrategy; } });
Object.defineProperty(exports, "syncIterator", { enumerable: true, get: function () { return internal_mod_1.syncIterator; } });
Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return internal_mod_1.TimeoutError; } });
Object.defineProperty(exports, "tokenAuthenticator", { enumerable: true, get: function () { return internal_mod_1.tokenAuthenticator; } });
Object.defineProperty(exports, "UserAuthenticationExpiredError", { enumerable: true, get: function () { return internal_mod_1.UserAuthenticationExpiredError; } });
Object.defineProperty(exports, "usernamePasswordAuthenticator", { enumerable: true, get: function () { return internal_mod_1.usernamePasswordAuthenticator; } });
Object.defineProperty(exports, "wsconnect", { enumerable: true, get: function () { return internal_mod_1.wsconnect; } });
//# sourceMappingURL=mod.js.map
import { ProtocolHandler } from "./protocol";
import type { Features, SemVer } from "./semver";
import type { Dispatcher } from "./core";
import type { ConnectionOptions, Context, Msg, NatsConnection, Payload, PublishOptions, QueuedIterator, RequestManyOptions, RequestOptions, ServerInfo, Stats, Status, Subscription, SubscriptionOptions } from "./core";
import type { ConnectionOptions, Context, Dispatcher, Msg, NatsConnection, Payload, PublishOptions, QueuedIterator, RequestManyOptions, RequestOptions, ServerInfo, Stats, Status, Subscription, SubscriptionOptions } from "./core";
export declare class NatsConnectionImpl implements NatsConnection {

@@ -6,0 +5,0 @@ options: ConnectionOptions;

@@ -80,2 +80,5 @@ "use strict";

this._check(subject, false, true);
if (options?.reply) {
this._check(options.reply, false, true);
}
this.protocol.publish(subject, data, options);

@@ -142,3 +145,3 @@ }

if (opts.maxWait < 1) {
return Promise.reject(new errors_1.errors.InvalidArgumentError(errors_1.InvalidArgumentError.format("timeout", "must be greater than 0")));
return Promise.reject(errors_1.InvalidArgumentError.format("timeout", "must be greater than 0"));
}

@@ -286,6 +289,6 @@ // the iterator for user results

if (opts.timeout < 1) {
return Promise.reject(new errors_1.errors.InvalidArgumentError(errors_1.InvalidArgumentError.format("timeout", `must be greater than 0`)));
return Promise.reject(errors_1.InvalidArgumentError.format("timeout", `must be greater than 0`));
}
if (!opts.noMux && opts.reply) {
return Promise.reject(new errors_1.errors.InvalidArgumentError(errors_1.InvalidArgumentError.formatMultiple(["reply", "noMux"], "are mutually exclusive")));
return Promise.reject(errors_1.InvalidArgumentError.format(["reply", "noMux"], "are mutually exclusive"));
}

@@ -302,3 +305,3 @@ if (opts.noMux) {

callback: (err, msg) => {
// check for no responders
// check for no responders status
if (msg && msg.data?.length === 0 && msg.headers?.code === 503) {

@@ -308,11 +311,13 @@ err = new errors_1.errors.NoRespondersError(subject);

if (err) {
// if we have a context, use that as the wrapper
if (errCtx) {
errCtx.message = err.message;
errCtx.cause = err;
err = errCtx;
// we have a proper stack on timeout
if (!(err instanceof errors_1.TimeoutError)) {
if (errCtx) {
errCtx.message = err.message;
errCtx.cause = err;
err = errCtx;
}
else {
err = new errors_1.errors.RequestError(err.message, { cause: err });
}
}
else {
err = new errors_1.errors.RequestError(err.message, { cause: err });
}
d.reject(err);

@@ -319,0 +324,0 @@ sub.unsubscribe();

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

if (opts.servers.length > 0 && opts.port) {
throw new errors_1.errors.InvalidArgumentError(errors_1.errors.InvalidArgumentError.formatMultiple(["servers", "port"], "are mutually exclusive"));
throw errors_1.InvalidArgumentError.format(["servers", "port"], "are mutually exclusive");
}

@@ -118,3 +118,3 @@ if (opts.servers.length === 0 && opts.port) {

if (typeof (0, transport_1.getResolveFn)() !== "function") {
throw new errors_1.errors.InvalidArgumentError(errors_1.errors.InvalidArgumentError.format("resolve", "is not supported in the current runtime"));
throw errors_1.InvalidArgumentError.format("resolve", "is not supported in the current runtime");
}

@@ -136,5 +136,5 @@ }

if (v) {
throw new errors_1.errors.InvalidArgumentError(errors_1.errors.InvalidArgumentError.format(prop, "is not supported"));
throw errors_1.InvalidArgumentError.format(prop, "is not supported");
}
}
//# sourceMappingURL=options.js.map

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

if (this.info && !this.info.headers) {
throw new errors_1.errors.InvalidArgumentError(errors_1.errors.InvalidArgumentError.format("headers", "are not available on this server"));
errors_1.InvalidArgumentError.format("headers", "are not available on this server");
}

@@ -754,3 +754,3 @@ const hdrs = options.headers;

if (this.info && len > this.info.max_payload) {
throw new errors_1.errors.InvalidArgumentError(errors_1.errors.InvalidArgumentError.format("payload", "max_payload size exceeded"));
throw errors_1.InvalidArgumentError.format("payload", "max_payload size exceeded");
}

@@ -757,0 +757,0 @@ this.outBytes += len;

@@ -109,10 +109,13 @@ "use strict";

if (err) {
if (this.ctx) {
this.ctx.message = err.message;
this.ctx.cause = err;
err = this.ctx;
// we have proper stack on timeout
if (!(err instanceof errors_1.TimeoutError)) {
if (this.ctx) {
this.ctx.message = err.message;
this.ctx.cause = err;
err = this.ctx;
}
else {
err = new errors_1.errors.RequestError(err.message, { cause: err });
}
}
else {
err = new errors_1.RequestError(err.message, { cause: err });
}
this.deferred.reject(err);

@@ -119,0 +122,0 @@ }

@@ -91,7 +91,13 @@ "use strict";

}
function deadline(p, millis = 1000) {
const err = new Error(`deadline exceeded`);
async function deadline(p, millis = 1000) {
const d = deferred();
const timer = setTimeout(() => d.reject(err), millis);
return Promise.race([p, d]).finally(() => clearTimeout(timer));
const timer = setTimeout(() => {
d.reject(new errors_1.TimeoutError());
}, millis);
try {
return await Promise.race([p, d]);
}
finally {
clearTimeout(timer);
}
}

@@ -98,0 +104,0 @@ /**

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

export declare const version = "3.0.0-32";
export declare const version = "3.0.0-34";

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

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

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

if (opts.tls) {
throw new errors_1.errors.InvalidArgumentError(errors_1.InvalidArgumentError.format("tls", "is not configurable on w3c websocket connections"));
throw errors_1.InvalidArgumentError.format("tls", "is not configurable on w3c websocket connections");
}

@@ -302,0 +302,0 @@ return new WsTransport();

{
"name": "@nats-io/nats-core",
"version": "3.0.0-32",
"version": "3.0.0-34",
"files": [

@@ -5,0 +5,0 @@ "lib/",

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

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