Skip to content

Commit

Permalink
[BUMP] nbc to 1.10.0, merge changes from main
Browse files Browse the repository at this point in the history
# Conflicts:
#	package-lock.json
#	package.json
#	src/connect.ts
#	src/mod.ts
#	src/nats-base-client.ts
#	src/ws_transport.ts
  • Loading branch information
aricart committed Dec 19, 2022
2 parents e89f712 + d9b0a03 commit 18f9f37
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 56 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nats.ws",
"version": "1.11.0-0",
"version": "1.11.0",
"description": "WebSocket NATS client",
"main": "./cjs/nats.js",
"module": "./esm/nats.js",
Expand Down
2 changes: 1 addition & 1 deletion src/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
setTransportFactory,
Transport,
TransportFactory,
} from "https://raw.githubusercontent.com/nats-io/nats.deno/dev/nats-base-client/internal_mod.ts";
} from "https://raw.githubusercontent.com/nats-io/nats.deno/v1.10.0/nats-base-client/internal_mod.ts";

import { WsTransport } from "./ws_transport.ts";

Expand Down
2 changes: 1 addition & 1 deletion src/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from "https://raw.githubusercontent.com/nats-io/nats.deno/dev/nats-base-client/mod.ts";
export * from "https://raw.githubusercontent.com/nats-io/nats.deno/v1.10.0/nats-base-client/mod.ts";
export { connect } from "./connect.ts";
2 changes: 1 addition & 1 deletion src/nats-base-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
* limitations under the License.
*/
// this import here to drive the build system
export * from "https://raw.githubusercontent.com/nats-io/nats.deno/dev/nats-base-client/internal_mod.ts";
export * from "https://raw.githubusercontent.com/nats-io/nats.deno/v1.10.0/nats-base-client/internal_mod.ts";
6 changes: 3 additions & 3 deletions src/ws_transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type {
Server,
ServerInfo,
Transport,
} from "https://raw.githubusercontent.com/nats-io/nats.deno/dev/nats-base-client/internal_mod.ts";
} from "https://raw.githubusercontent.com/nats-io/nats.deno/v1.10.0/nats-base-client/internal_mod.ts";
import {
checkOptions,
DataBuffer,
Expand All @@ -30,9 +30,9 @@ import {
INFO,
NatsError,
render,
} from "https://raw.githubusercontent.com/nats-io/nats.deno/dev/nats-base-client/internal_mod.ts";
} from "https://raw.githubusercontent.com/nats-io/nats.deno/v1.10.0/nats-base-client/internal_mod.ts";

const VERSION = "1.11.0-0";
const VERSION = "1.11.0";
const LANG = "nats.ws";

export type WsSocketFactory = (u: string, opts: ConnectionOptions) => Promise<{
Expand Down
2 changes: 1 addition & 1 deletion test/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ test("auth - custom error", async (t) => {
).then(() => {
t.fail("shouldn't have connected");
}).catch((err) => {
t.is(err.code, ErrorCode.BadAuthentication);
t.is(err.message, "user code exploded");
});
await ns.stop();
});
Expand Down
64 changes: 16 additions & 48 deletions test/basics.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const { deferred, delay } = require(
"../lib/nats-base-client/internal_mod",
);
const { Lock } = require("./helpers/lock");
const { NatsServer, wsConfig, tlsConfig } = require("./helpers/launcher");
const { NatsServer, wsConfig } = require("./helpers/launcher");
const { parseOptions } = require("../lib/nats-base-client/options");

test("basics - connect", async (t) => {
const ns = await NatsServer.start(wsConfig());
Expand All @@ -33,19 +34,16 @@ test("basics - connect", async (t) => {
});

test("basics - wss connection", async (t) => {
const conf = {
websocket: {
port: -1,
tls: tlsConfig(),
},
};

const ns = await NatsServer.start(conf);
const nc = await connect({ servers: `wss://localhost:${ns.websocket}` });
await nc.flush();
await nc.close();
await ns.stop();
t.pass();
const servers = "wss://demo.nats.io:8443";
try {
const nc = await connect({ servers });
await nc.flush();
await nc.close();
t.is(nc.protocol.transport?.isEncrypted(), true);
t.pass();
} catch (err) {
t.fail(err.message);
}
});

test("basics - publish", async (t) => {
Expand Down Expand Up @@ -659,20 +657,12 @@ test("basics - disconnect reconnects", async (t) => {
});

test("basics - wsnats doesn't support tls options", async (t) => {
const conf = {
websocket: {
port: -1,
tls: tlsConfig(),
},
};
const ns = await NatsServer.start(conf);
try {
await connect({ servers: `wss://localhost:${ns.websocket}`, tls: {} });
await connect({ servers: "wss://demo.nats.io:8443", tls: {} });
t.fail(`should have failed with ${ErrorCode.InvalidOption}`);
} catch (err) {
t.is(err.code, ErrorCode.InvalidOption);
}
await ns.stop();
t.pass();
});

Expand Down Expand Up @@ -702,29 +692,7 @@ test("basics - drain connection publisher", async (t) => {
});

test("basics - default connection", async (t) => {
t.plan(1);
if (process.env.GITHUB_ACTIONS) {
t.log("skipping on github actions");
t.pass();
return;
}

const ns = await NatsServer.start(
{
websocket: {
port: 443,
tls: tlsConfig(),
},
},
);
const nc = await connect();
try {
const subj = createInbox();
await nc.request(subj);
t.fail("expected request to fail");
} catch (err) {
t.is(err.code, ErrorCode.NoResponders);
}
await nc.close();
await ns.stop();
const opts = parseOptions({});
t.is(opts.servers.length, 1);
t.is(opts.servers[0], `127.0.0.1:443`);
});

0 comments on commit 18f9f37

Please sign in to comment.