Socket
Socket
Sign inDemoInstall

nats.ws

Package Overview
Dependencies
2
Maintainers
2
Versions
109
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.19.1 to 1.20.0

14

lib/jetstream/consumer.d.ts

@@ -103,4 +103,4 @@ import { Timeout } from "../nats-base-client/util";

/**
* Notification that the consumer was not found. Consumers that yielded at least
* one message will be retried for more messages regardless of the not being found
* Notification that the consumer was not found. Consumers that were accessible at
* least once, will be retried for more messages regardless of the not being found
* or timeouts etc. This notification includes a count of consecutive attempts to

@@ -113,2 +113,12 @@ * find the consumer. Note that if you get this notification possibly your code should

/**
* Notification that the stream was not found. Consumers were accessible at least once,
* will be retried for more messages regardless of the not being found
* or timeouts etc. This notification includes a count of consecutive attempts to
* find the consumer. Note that if you get this notification possibly your code should
* attempt to recreate the consumer. Note that this notification is only informational
* for ordered consumers, as the consumer will be created in those cases automatically.
*/
StreamNotFound = "stream_not_found",
ConsumerDeleted = "consumer_deleted",
/**
* This notification is specific of ordered consumers and will be notified whenever

@@ -115,0 +125,0 @@ * the consumer is recreated. The argument is the name of the newly created consumer.

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

/**
* Notification that the consumer was not found. Consumers that yielded at least
* one message will be retried for more messages regardless of the not being found
* Notification that the consumer was not found. Consumers that were accessible at
* least once, will be retried for more messages regardless of the not being found
* or timeouts etc. This notification includes a count of consecutive attempts to

@@ -73,2 +73,17 @@ * find the consumer. Note that if you get this notification possibly your code should

/**
* Notification that the stream was not found. Consumers were accessible at least once,
* will be retried for more messages regardless of the not being found
* or timeouts etc. This notification includes a count of consecutive attempts to
* find the consumer. Note that if you get this notification possibly your code should
* attempt to recreate the consumer. Note that this notification is only informational
* for ordered consumers, as the consumer will be created in those cases automatically.
*/
ConsumerEvents["StreamNotFound"] = "stream_not_found";
/*
* Notification that the consumer was deleted. This notification
* means the consumer will not get messages unless it is recreated. The client
* will continue to attempt to pull messages. Ordered consumer will recreate it.
*/
ConsumerEvents["ConsumerDeleted"] = "consumer_deleted";
/**
* This notification is specific of ordered consumers and will be notified whenever

@@ -194,4 +209,3 @@ * the consumer is recreated. The argument is the name of the newly created consumer.

else if (code === 409 && description === "consumer deleted") {
const error = toErr();
this.stop(error);
this.notify(ConsumerEvents.ConsumerDeleted, `${code} ${description}`);
}

@@ -341,2 +355,3 @@ else {

let notFound = 0;
let streamNotFound = 0;
const bo = (0, util_1.backoff)();

@@ -363,3 +378,7 @@ let attempt = 0;

// game over
if (err.message === "consumer not found") {
if (err.message === "stream not found") {
streamNotFound++;
this.notify(ConsumerEvents.StreamNotFound, streamNotFound);
}
else if (err.message === "consumer not found") {
notFound++;

@@ -381,2 +400,3 @@ this.notify(ConsumerEvents.ConsumerNotFound, notFound);

notFound = 0;
streamNotFound = 0;
}

@@ -383,0 +403,0 @@ const to = bo.backoff(attempt);

20

lib/jetstream/jslister.js

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

var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }

@@ -55,3 +56,8 @@ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }

// all the entries returned
this.offset += this.countResponse(r);
const count = this.countResponse(r);
if (count === 0) {
// we are done if we get a null set of infos
return [];
}
this.offset += count;
const a = this.filter(r);

@@ -67,13 +73,13 @@ return a;

countResponse(r) {
var _a;
var _a, _b, _c;
switch (r === null || r === void 0 ? void 0 : r.type) {
case "io.nats.jetstream.api.v1.stream_names_response":
case "io.nats.jetstream.api.v1.stream_list_response":
return r.streams.length;
return ((_a = r.streams) === null || _a === void 0 ? void 0 : _a.length) || 0;
case "io.nats.jetstream.api.v1.consumer_list_response":
return r.consumers.length;
return ((_b = r.consumers) === null || _b === void 0 ? void 0 : _b.length) || 0;
default:
console.error(`jslister.ts: unknown API response for paged output: ${r === null || r === void 0 ? void 0 : r.type}`);
// has to be a stream...
return ((_a = r.streams) === null || _a === void 0 ? void 0 : _a.length) || 0;
return ((_c = r.streams) === null || _c === void 0 ? void 0 : _c.length) || 0;
}

@@ -80,0 +86,0 @@ return 0;

@@ -35,3 +35,3 @@ import { Msg, Nanos, NatsError } from "../nats-base-client/core";

PushConsumer = "consumer is push based",
MaxWaitingExceeded = "exceeded maxwaiting",
MaxWaitingExceeded = "exceeded maxwaiting",// not terminal
IdleHeartbeatMissed = "idle heartbeats missed",

@@ -38,0 +38,0 @@ ConsumerDeleted = "consumer deleted"

@@ -1165,3 +1165,3 @@ import { JetStreamClient, JetStreamManager } from "../jetstream/types";

export interface URLParseFn {
(u: string): string;
(u: string, encrypted?: boolean): string;
}

@@ -1168,0 +1168,0 @@ export declare enum ServiceVerb {

@@ -106,2 +106,3 @@ import { Transport } from "./transport";

abortReconnect: boolean;
whyClosed: string;
servers: Servers;

@@ -108,0 +109,0 @@ server: ServerImpl;

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

this.pongs = [];
this.whyClosed = "";
//@ts-ignore: options.pendingLimit is hidden

@@ -673,3 +674,3 @@ this.pendingLimit = options.pendingLimit || this.pendingLimit;

? undefined
: this.servers.update(info);
: this.servers.update(info, this.transport.isEncrypted());
if (!this.infoReceived) {

@@ -884,2 +885,3 @@ this.features.update((0, semver_1.parseSemVer)(info.version));

}
this.whyClosed = new Error("close trace").stack || "";
this.heartbeats.cancel();

@@ -886,0 +888,0 @@ if (this.connectError) {

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

var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }

@@ -10,0 +11,0 @@ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }

@@ -53,3 +53,3 @@ import { DnsResolveFn, Server, ServerInfo, ServersChanged } from "./core";

getServers(): ServerImpl[];
update(info: ServerInfo): ServersChanged;
update(info: ServerInfo, encrypted?: boolean): ServersChanged;
}

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

}
update(info) {
update(info, encrypted) {
const added = [];

@@ -245,3 +245,3 @@ let deleted = [];

info.connect_urls.forEach((hp) => {
hp = urlParseFn ? urlParseFn(hp) : hp;
hp = urlParseFn ? urlParseFn(hp, encrypted) : hp;
const s = new ServerImpl(hp, true);

@@ -248,0 +248,0 @@ discovered.set(hp, s);

import { ConnectionOptions, NatsConnection } from "../nats-base-client/internal_mod";
export declare function wsUrlParseFn(u: string): string;
export declare function wsUrlParseFn(u: string, encrypted?: boolean): string;
export declare function connect(opts?: ConnectionOptions): Promise<NatsConnection>;

@@ -20,9 +20,22 @@ "use strict";

const ws_transport_1 = require("./ws_transport");
function wsUrlParseFn(u) {
function wsUrlParseFn(u, encrypted) {
const ut = /^(.*:\/\/)(.*)/;
if (!ut.test(u)) {
u = `https://${u}`;
// if we have no hint to encrypted and no protocol, assume encrypted
// else we fix the url from the update to match
if (typeof encrypted === "boolean") {
u = `${encrypted === true ? "https" : "http"}://${u}`;
}
else {
u = `https://${u}`;
}
}
let url = new URL(u);
const srcProto = url.protocol.toLowerCase();
if (srcProto === "ws:") {
encrypted = false;
}
if (srcProto === "wss:") {
encrypted = true;
}
if (srcProto !== "https:" && srcProto !== "http") {

@@ -44,6 +57,12 @@ u = u.replace(/^(.*:\/\/)(.*)/gm, "$2");

break;
default:
case "https:":
case "wss:":
case "tls:":
port = url.port || "443";
protocol = "wss:";
break;
default:
port = url.port || encrypted === true ? "443" : "80";
protocol = encrypted === true ? "wss:" : "ws:";
break;
}

@@ -50,0 +69,0 @@ return `${protocol}//${host}:${port}${path}${search}`;

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

var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }

@@ -41,3 +42,3 @@ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }

const internal_mod_1 = require("../nats-base-client/internal_mod");
const VERSION = "1.19.1";
const VERSION = "1.20.0";
const LANG = "nats.ws";

@@ -44,0 +45,0 @@ class WsTransport {

{
"name": "nats.ws",
"version": "1.19.1",
"version": "1.20.0",
"description": "WebSocket NATS client",

@@ -45,3 +45,7 @@ "main": "./cjs/nats.js",

"check-package": "deno run --allow-all bin/check-bundle-version.ts",
"debug-test": "node node_modules/.bin/ava --verbose -T 6500000 --match"
"debug-test": "node node_modules/.bin/ava --verbose -T 6500000 --match",
"version": "deno run -A bin/update-transport-version.ts && git add src/ws_transport.ts",
"postversion": "git push && git push --tags",
"bump-qualifier": "npm version prerelease --no-commit-hooks --no-git-tag-version",
"bump-release": "npm version patch --no-commit-hooks --no-git-tag-version"
},

@@ -52,9 +56,9 @@ "optionalDependencies": {

"devDependencies": {
"@types/node": "^20.6.x",
"@types/node": "^20.10.x",
"ava": "^5.3.x",
"minimist": "^1.2.8",
"nats-jwt": "^0.0.5",
"nats-jwt": "^0.0.7",
"shx": "^0.3.3",
"tslint": "^6.1.3",
"typescript": "^5.2.x",
"typescript": "^5.3.x",
"web-streams-polyfill": "^3.2.1",

@@ -61,0 +65,0 @@ "websocket": "^1.0.34",

Sorry, the diff of this file is too big to display

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

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

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

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc