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-42 to 3.0.0-44

18

lib/core.d.ts

@@ -236,8 +236,3 @@ export type DisconnectStatus = {

}
export declare enum RequestStrategy {
Timer = "timer",
Count = "count",
JitterTimer = "jitterTimer",
SentinelMsg = "sentinelMsg"
}
export type RequestStrategy = "timer" | "count" | "stall" | "sentinel";
export interface RequestManyOptions {

@@ -249,3 +244,3 @@ strategy: RequestStrategy;

noMux?: boolean;
jitter?: number;
stall?: number;
}

@@ -465,5 +460,10 @@ export interface Stats {

export interface Subscription extends AsyncIterable<Msg> {
/** A promise that resolves when the subscription closes */
closed: Promise<void>;
/**
* A promise that resolves when the subscription closes. If the promise
* resolves to an error, the subscription was closed because of an error
* typically a permissions error. Note that this promise doesn't reject, but
* rather resolves to void (no error) or an Error
*/
closed: Promise<void | Error>;
/**
* Stop the subscription from receiving messages. You can optionally

@@ -470,0 +470,0 @@ * specify that the subscription should stop after the specified number

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_HOST = exports.DEFAULT_PORT = exports.RequestStrategy = exports.Match = void 0;
exports.DEFAULT_HOST = exports.DEFAULT_PORT = exports.Match = void 0;
exports.syncIterator = syncIterator;

@@ -32,9 +32,2 @@ exports.createInbox = createInbox;

})(Match || (exports.Match = Match = {}));
var RequestStrategy;
(function (RequestStrategy) {
RequestStrategy["Timer"] = "timer";
RequestStrategy["Count"] = "count";
RequestStrategy["JitterTimer"] = "jitterTimer";
RequestStrategy["SentinelMsg"] = "sentinelMsg";
})(RequestStrategy || (exports.RequestStrategy = RequestStrategy = {}));
/**

@@ -41,0 +34,0 @@ * syncIterator is a utility function that allows an AsyncIterator to be triggered

@@ -31,4 +31,4 @@ export { NatsConnectionImpl } from "./nats";

export { extractProtocolMessage, protoLen } from "./transport";
export type { Auth, Authenticator, CallbackFn, ClientPingStatus, ClusterUpdateStatus, ConnectionOptions, DisconnectStatus, Dispatcher, ForceReconnectStatus, JwtAuth, LDMStatus, Msg, MsgCallback, MsgHdrs, Nanos, NatsConnection, NKeyAuth, NoAuth, Payload, Publisher, PublishOptions, QueuedIterator, ReconnectingStatus, ReconnectStatus, Request, RequestManyOptions, RequestOptions, ReviverFn, Server, ServerErrorStatus, ServerInfo, ServersChanged, SlowConsumerStatus, StaleConnectionStatus, Stats, Status, SubOpts, Subscription, SubscriptionOptions, SyncIterator, TlsOptions, TokenAuth, UserPass, } from "./core";
export { createInbox, Match, RequestStrategy, syncIterator } from "./core";
export type { Auth, Authenticator, CallbackFn, ClientPingStatus, ClusterUpdateStatus, ConnectionOptions, DisconnectStatus, Dispatcher, ForceReconnectStatus, JwtAuth, LDMStatus, Msg, MsgCallback, MsgHdrs, Nanos, NatsConnection, NKeyAuth, NoAuth, Payload, Publisher, PublishOptions, QueuedIterator, ReconnectingStatus, ReconnectStatus, Request, RequestManyOptions, RequestOptions, RequestStrategy, ReviverFn, Server, ServerErrorStatus, ServerInfo, ServersChanged, SlowConsumerStatus, StaleConnectionStatus, Stats, Status, SubOpts, Subscription, SubscriptionOptions, SyncIterator, TlsOptions, TokenAuth, UserPass, } from "./core";
export { createInbox, Match, syncIterator } from "./core";
export { SubscriptionImpl, Subscriptions } from "./protocol";

@@ -35,0 +35,0 @@ export type { IdleHeartbeatFn, IdleHeartbeatOptions, } from "./idleheartbeat_monitor";

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

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.hasWsProtocol = 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.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.createInbox = exports.protoLen = exports.extractProtocolMessage = exports.Empty = exports.parseSemVer = exports.Features = exports.Feature = exports.compare = exports.parseIP = exports.isIP = exports.ipV4 = exports.TE = 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.Match = exports.createInbox = exports.protoLen = exports.extractProtocolMessage = exports.Empty = exports.parseSemVer = exports.Features = exports.Feature = exports.compare = exports.parseIP = exports.isIP = exports.ipV4 = exports.TE = void 0;
var nats_1 = require("./nats");

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

Object.defineProperty(exports, "Match", { enumerable: true, get: function () { return core_1.Match; } });
Object.defineProperty(exports, "RequestStrategy", { enumerable: true, get: function () { return core_1.RequestStrategy; } });
Object.defineProperty(exports, "syncIterator", { enumerable: true, get: function () { return core_1.syncIterator; } });

@@ -124,0 +123,0 @@ var protocol_2 = require("./protocol");

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

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

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

Object.defineProperty(exports, "__esModule", { value: true });
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.hasWsProtocol = exports.errors = exports.Empty = exports.DrainingConnectionError = exports.delay = exports.deferred = exports.deadline = exports.credsAuthenticator = exports.createInbox = exports.ConnectionError = exports.ClosedConnectionError = exports.canonicalMIMEHeaderKey = exports.buildAuthenticator = exports.Bench = exports.backoff = exports.AuthorizationError = void 0;
exports.wsconnect = exports.usernamePasswordAuthenticator = exports.UserAuthenticationExpiredError = exports.tokenAuthenticator = exports.TimeoutError = exports.syncIterator = 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.hasWsProtocol = exports.errors = exports.Empty = exports.DrainingConnectionError = exports.delay = exports.deferred = 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");

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

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; } });

@@ -57,0 +56,0 @@ Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return internal_mod_1.TimeoutError; } });

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

}
opts.strategy = opts.strategy || core_1.RequestStrategy.Timer;
opts.strategy = opts.strategy || "timer";
opts.maxWait = opts.maxWait || 1000;

@@ -189,3 +189,3 @@ if (opts.maxWait < 1) {

// see if the m request is completed
if (opts.strategy === core_1.RequestStrategy.Count) {
if (opts.strategy === "count") {
max--;

@@ -196,3 +196,3 @@ if (max === 0) {

}
if (opts.strategy === core_1.RequestStrategy.JitterTimer) {
if (opts.strategy === "stall") {
clearTimers();

@@ -203,3 +203,3 @@ timer = setTimeout(() => {

}
if (opts.strategy === core_1.RequestStrategy.SentinelMsg) {
if (opts.strategy === "sentinel") {
if (msg && msg.data.length === 0) {

@@ -206,0 +206,0 @@ cancel();

@@ -55,3 +55,3 @@ import type { Transport } from "./transport";

cleanupFn?: (sub: Subscription, info?: unknown) => void;
closed: Deferred<void>;
closed: Deferred<void | Error>;
requestSubject?: string;

@@ -62,3 +62,3 @@ slow?: SlowNotifier;

callback(err: Error | null, msg: Msg): void;
close(): void;
close(err?: Error): void;
unsubscribe(max?: number): void;

@@ -65,0 +65,0 @@ cancelTimeout(): void;

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

// make sure we clean up, if they didn't call unsub
this.iterClosed.then(() => {
this.closed.resolve();
this.iterClosed.then((err) => {
this.closed.resolve(err);
this.unsubscribe();

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

}
close() {
close(err) {
if (!this.isClosed()) {

@@ -169,3 +169,3 @@ this.cancelTimeout();

}
this.closed.resolve();
this.closed.resolve(err);
};

@@ -286,3 +286,3 @@ if (this.noIterator) {

sub.callback(err, {});
sub.close();
sub.close(err);
this.subs.delete(sub.sid);

@@ -289,0 +289,0 @@ return sub !== this.mux;

@@ -6,3 +6,2 @@ "use strict";

const nuid_1 = require("./nuid");
const core_1 = require("./core");
const errors_1 = require("./errors");

@@ -74,3 +73,3 @@ class BaseRequest {

this.callback(null, msg);
if (this.opts.strategy === core_1.RequestStrategy.Count) {
if (this.opts.strategy === "count") {
this.max--;

@@ -81,3 +80,3 @@ if (this.max === 0) {

}
if (this.opts.strategy === core_1.RequestStrategy.JitterTimer) {
if (this.opts.strategy === "stall") {
clearTimeout(this.timer);

@@ -87,5 +86,5 @@ // @ts-ignore: node is not a number

this.cancel();
}, this.opts.jitter || 300);
}, this.opts.stall || 300);
}
if (this.opts.strategy === core_1.RequestStrategy.SentinelMsg) {
if (this.opts.strategy === "sentinel") {
if (msg && msg.data.length === 0) {

@@ -92,0 +91,0 @@ this.cancel();

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

export declare const version = "3.0.0-42";
export declare const version = "3.0.0-44";

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

// This file is generated - do not edit
exports.version = "3.0.0-42";
exports.version = "3.0.0-44";
//# sourceMappingURL=version.js.map
{
"name": "@nats-io/nats-core",
"version": "3.0.0-42",
"version": "3.0.0-44",
"files": [

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

@@ -16,4 +16,4 @@ # Core

functionality that uses a NATS client connection without binding your code to a
particular JavaScript runtime. For example, the @nats-io/jetstream library
depends on @nats-io/nats-core to implement all of its JetStream protocol.
particular runtime. For example, the @nats-io/jetstream library depends on
@nats-io/nats-core to implement all of its JetStream protocol.

@@ -27,2 +27,7 @@ ## WebSocket Support

Note that wsconnect assumes `wss://` connections. If you provide a port, it
likewise resolve to `wss://localhost:443`. If you specify a `ws://` URL, the
client assumes port 80, which is likely not the port. Check your server
configuration as the port for WebSocket protocol is NOT 4222.
# Installation

@@ -60,3 +65,3 @@

```bash
deno add @nats-io/nats-core
deno add jsr:@nats-io/nats-core
```

@@ -113,3 +118,3 @@

// import the connect function from a transport
import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7";
import { connect } from "@nats-io/transport-deno";

@@ -186,3 +191,3 @@ const servers = [

// import the connect function from a transport
import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7";
import { connect } from "@nats-io/transport-deno";

@@ -249,4 +254,4 @@ // to create a connection to a nats-server:

```typescript
import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7";
import type { Subscription } from "jsr:@nats-io/transport-deno@3.0.0-7";
import { connect } from "@nats-io/transport-deno";
import type { Subscription } from "@nats-io/transport-deno";
const nc = await connect({ servers: "demo.nats.io:4222" });

@@ -427,7 +432,4 @@

```typescript
import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7";
import type {
NatsConnection,
Subscription,
} from "jsr:@nats-io/transport-deno@3.0.0-7";
import { connect } from "@nats-io/transport-deno";
import type { NatsConnection, Subscription } from "@nats-io/transport-deno";

@@ -551,3 +553,3 @@ async function createService(

```typescript
import { connect } from "jsr:@nats-io/transport-deno@3.0.0-7";
import { connect } from "@nats-io/transport-deno";
import {

@@ -557,3 +559,3 @@ NoRespondersError,

TimeoutError,
} from "jsr:@nats-io/transport-deno@3.0.0-7";
} from "@nats-io/transport-deno";

@@ -607,3 +609,3 @@ const nc = await connect({

// `token` options in the NatsConnectionOptions
import { connect } from "jsr:@nats-io/transport-deno@3.0.0-5";
import { connect } from "@nats-io/transport-deno";

@@ -610,0 +612,0 @@ const nc1 = await connect({

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