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

nats

Package Overview
Dependencies
Maintainers
3
Versions
195
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nats - npm Package Compare versions

Comparing version 2.6.1 to 2.7.0-1

lib/nats-base-client/semver.d.ts

2

lib/nats-base-client/internal_mod.d.ts

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

export { Base64KeyCodec, Bucket, defaultBucketOpts, NoopKvCodecs, } from "./kv";
export type { SemVer } from "./semver";
export { compare, parseSemVer } from "./semver";

5

lib/nats-base-client/internal_mod.js

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

exports.QueuedIteratorImpl = exports.StringCodec = exports.JSONCodec = exports.nkeyAuthenticator = exports.jwtAuthenticator = exports.credsAuthenticator = exports.Request = exports.checkUnsupportedOption = exports.checkOptions = exports.DataBuffer = exports.MuxSubscription = exports.Heartbeat = exports.MsgHdrsImpl = exports.Match = exports.headers = exports.canonicalMIMEHeaderKey = exports.timeout = exports.render = exports.extractProtocolMessage = exports.extend = exports.delay = exports.deferred = exports.collect = exports.ProtocolHandler = exports.INFO = exports.createInbox = exports.Connect = exports.setTransportFactory = exports.Subscriptions = exports.SubscriptionImpl = exports.MsgImpl = exports.JsHeaders = exports.Events = exports.Empty = exports.DebugEvents = exports.toJsMsg = exports.consumerOpts = exports.StorageType = exports.RetentionPolicy = exports.ReplayPolicy = exports.DiscardPolicy = exports.DeliverPolicy = exports.AdvisoryKind = exports.AckPolicy = exports.NatsError = exports.isNatsError = exports.ErrorCode = exports.nuid = exports.Nuid = exports.NatsConnectionImpl = void 0;
exports.NoopKvCodecs = exports.defaultBucketOpts = exports.Bucket = exports.Base64KeyCodec = exports.nanos = exports.millis = exports.isHeartbeatMsg = exports.isFlowControlMsg = exports.checkJsError = exports.TypedSubscription = exports.parseIP = exports.isIP = exports.TE = exports.TD = exports.Metric = exports.Bench = exports.writeAll = exports.readAll = exports.MAX_SIZE = exports.DenoBuffer = exports.State = exports.Parser = exports.Kind = void 0;
exports.parseSemVer = exports.compare = exports.NoopKvCodecs = exports.defaultBucketOpts = exports.Bucket = exports.Base64KeyCodec = exports.nanos = exports.millis = exports.isHeartbeatMsg = exports.isFlowControlMsg = exports.checkJsError = exports.TypedSubscription = exports.parseIP = exports.isIP = exports.TE = exports.TD = exports.Metric = exports.Bench = exports.writeAll = exports.readAll = exports.MAX_SIZE = exports.DenoBuffer = exports.State = exports.Parser = exports.Kind = void 0;
var nats_1 = require("./nats");

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

Object.defineProperty(exports, "NoopKvCodecs", { enumerable: true, get: function () { return kv_1.NoopKvCodecs; } });
var semver_1 = require("./semver");
Object.defineProperty(exports, "compare", { enumerable: true, get: function () { return semver_1.compare; } });
Object.defineProperty(exports, "parseSemVer", { enumerable: true, get: function () { return semver_1.parseSemVer; } });
//# sourceMappingURL=internal_mod.js.map

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

import { ConsumerConfig, JetStreamClient, JetStreamManager, JsMsg, KV, KvCodec, KvCodecs, KvEntry, KvOptions, KvPutOptions, KvRemove, KvStatus, PurgeOpts, PurgeResponse, StoredMsg } from "./types";
import { callbackFn, ConsumerConfig, JetStreamClient, JetStreamManager, JsMsg, KV, KvCodec, KvCodecs, KvEntry, KvOptions, KvPutOptions, KvRemove, KvStatus, PurgeOpts, PurgeResponse, StoredMsg } from "./types";
import { QueuedIterator } from "./queued_iterator";

@@ -54,2 +54,3 @@ import { MsgHdrs } from "./headers";

headers_only?: boolean;
initializedFn?: callbackFn;
}): Promise<QueuedIterator<KvEntry>>;

@@ -56,0 +57,0 @@ keys(k?: string): Promise<QueuedIterator<string>>;

"use strict";
/*
* Copyright 2021 The NATS Authors
* Copyright 2021-2022 The NATS Authors
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -40,2 +40,3 @@ * you may not use this file except in compliance with the License.

const mod_1 = require("./mod");
const semver_1 = require("./semver");
function Base64KeyCodec() {

@@ -178,3 +179,6 @@ return {

sc.storage = bo.storage;
sc.discard = types_1.DiscardPolicy.Old;
const nci = this.js.nc;
const have = nci.getServerVersion();
const discardNew = have ? (0, semver_1.compare)((0, semver_1.parseSemVer)("2.7.2"), have) >= 0 : false;
sc.discard = discardNew ? types_1.DiscardPolicy.New : types_1.DiscardPolicy.Old;
sc.num_replicas = bo.replicas;

@@ -443,2 +447,5 @@ if (bo.ttl) {

co.headers_only = opts.headers_only || false;
let fn = opts.initializedFn;
let count = 0;
let initialized = false;
const cc = this._buildCC(k, false, co);

@@ -458,5 +465,38 @@ const subj = cc.filter_subject;

qi.received++;
// count could have changed or has already been received
if (fn && (count > 0 && qi.received >= count || jm.info.pending === 0)) {
initialized = true;
//@ts-ignore: we are injecting an unexpected type
qi.push(fn);
fn = undefined;
}
}
});
const sub = yield this.js.subscribe(subj, copts);
// by the time we are here, likely the subscription got messages
if (fn) {
const { info: { last } } = sub;
// this doesn't sound correct - we should be looking for a seq number instead
// then if we see a greater one, we are done.
const expect = last.num_pending + last.delivered.consumer_seq;
// if the iterator already queued - the only issue is other modifications
// did happen like stream was pruned, and the ordered consumer reset, etc
// we won't get what we are expecting - so the notification will never fire
// the sentinel ought to be coming from the server
if (expect === 0 || qi.received >= expect) {
try {
fn();
}
catch (err) {
// fail it - there's something wrong in the user callback
qi.stop(err);
}
finally {
fn = undefined;
}
}
else {
count = expect;
}
}
qi._data = sub;

@@ -463,0 +503,0 @@ qi.iterClosed.then(() => {

import { ProtocolHandler } from "./protocol";
import { ConnectionOptions, JetStreamClient, JetStreamManager, JetStreamOptions, Msg, NatsConnection, PublishOptions, RequestOptions, ServerInfo, Stats, Status, Subscription, SubscriptionOptions } from "./types";
import type { SemVer } from "./semver";
import { QueuedIterator } from "./queued_iterator";

@@ -32,2 +33,3 @@ export declare class NatsConnectionImpl implements NatsConnection {

jetstream(opts?: JetStreamOptions): JetStreamClient;
getServerVersion(): SemVer | undefined;
}
"use strict";
/*
* Copyright 2018-2021 The NATS Authors
* Copyright 2018-2022 The NATS Authors
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -39,2 +39,3 @@ * you may not use this file except in compliance with the License.

const types_1 = require("./types");
const semver_1 = require("./semver");
const options_1 = require("./options");

@@ -272,4 +273,8 @@ const queued_iterator_1 = require("./queued_iterator");

}
getServerVersion() {
const info = this.info;
return info ? (0, semver_1.parseSemVer)(info.version) : undefined;
}
}
exports.NatsConnectionImpl = NatsConnectionImpl;
//# sourceMappingURL=nats.js.map

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

const err = ProtocolHandler.toError(s);
const handled = this.subscriptions.handleError(err);
if (!handled) {
this.dispatchStatus({ type: types_1.Events.Error, data: err.code });
}
this.subscriptions.handleError(err);
this.dispatchStatus({ type: types_1.Events.Error, data: err.code });
yield this.handleError(err);

@@ -353,3 +351,3 @@ });

}
if (err.isPermissionError() || err.isProtocolError()) {
if (err.isProtocolError()) {
yield this._close(err);

@@ -356,0 +354,0 @@ }

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

/*
* Copyright 2020-2021 The NATS Authors
* Copyright 2020-2022 The NATS Authors
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -53,2 +53,7 @@ * you may not use this file except in compliance with the License.

}
if (typeof v === "function") {
this.yields.push(v);
this.signal.resolve();
return;
}
const { ingest, protocol } = this.ingestionFilterFn

@@ -83,2 +88,15 @@ ? this.ingestionFilterFn(v, this.ctx || this)

for (let i = 0; i < yields.length; i++) {
// some iterators could inject a callback
if (typeof yields[i] === "function") {
const fn = yields[i];
try {
fn();
}
catch (err) {
// failed on the invocation - fail the iterator
// so they know to fix the callback
throw err;
}
continue;
}
// only pass messages that pass the filter

@@ -85,0 +103,0 @@ const ok = this.protocolFilterFn

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

this.iterClosed.then(() => {
this.closed.resolve();
this.unsubscribe();

@@ -51,0 +52,0 @@ });

@@ -689,2 +689,4 @@ import { NatsError } from "./error";

key?: string;
headers_only?: boolean;
initializedFn?: callbackFn;
}): Promise<QueuedIterator<KvEntry>>;

@@ -706,1 +708,2 @@ close(): Promise<void>;

}
export declare type callbackFn = () => void;

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

const dns = require("dns");
const VERSION = "2.6.1";
const VERSION = "2.7.0-1";
const LANG = "nats.js";

@@ -49,0 +49,0 @@ class NodeTransport {

{
"name": "nats",
"version": "2.6.1",
"version": "2.7.0-1",
"description": "Node.js client for NATS, a lightweight, high-performance cloud native messaging system",

@@ -43,3 +43,3 @@ "keywords": [

"clean": "shx rm -Rf ./lib/* ./nats-base-client ./.deps",
"clone-nbc": "shx mkdir -p ./.deps && cd ./.deps && git clone --branch v1.6.1 https://github.com/nats-io/nats.deno.git",
"clone-nbc": "shx mkdir -p ./.deps && cd ./.deps && git clone --branch main https://github.com/nats-io/nats.deno.git",
"fmt": "deno fmt ./src/ ./examples/ ./test/",

@@ -46,0 +46,0 @@ "prepack": "npm run clone-nbc && npm run cjs && npm run check-package && npm run build",

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