pulsar-client 1.11.1 → 1.12.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -20,7 +20,7 @@
20
20
 
21
21
  export interface ClientConfig {
22
22
  serviceUrl: string;
23
- authentication?: AuthenticationTls | AuthenticationAthenz | AuthenticationToken | AuthenticationOauth2;
23
+ authentication?: AuthenticationTls | AuthenticationAthenz | AuthenticationToken | AuthenticationOauth2 | AuthenticationBasic;
24
24
  operationTimeoutSeconds?: number;
25
25
  ioThreads?: number;
26
26
  messageListenerThreads?: number;
@@ -239,6 +239,13 @@ export class AuthenticationOauth2 {
239
239
  });
240
240
  }
241
241
 
242
+ export class AuthenticationBasic {
243
+ constructor(params: {
244
+ username: string;
245
+ password: string;
246
+ });
247
+ }
248
+
242
249
  export enum LogLevel {
243
250
  DEBUG = 0,
244
251
  INFO = 1,
package/index.js CHANGED
@@ -22,6 +22,7 @@ const AuthenticationTls = require('./src/AuthenticationTls');
22
22
  const AuthenticationAthenz = require('./src/AuthenticationAthenz');
23
23
  const AuthenticationToken = require('./src/AuthenticationToken');
24
24
  const AuthenticationOauth2 = require('./src/AuthenticationOauth2');
25
+ const AuthenticationBasic = require('./src/AuthenticationBasic');
25
26
  const Client = require('./src/Client');
26
27
 
27
28
  const LogLevel = {
@@ -40,6 +41,7 @@ const Pulsar = {
40
41
  AuthenticationAthenz,
41
42
  AuthenticationToken,
42
43
  AuthenticationOauth2,
44
+ AuthenticationBasic,
43
45
  LogLevel,
44
46
  };
45
47
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pulsar-client",
3
- "version": "1.11.1",
3
+ "version": "1.12.0-rc.1",
4
4
  "description": "Pulsar Node.js client",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -1,2 +1,2 @@
1
- CPP_CLIENT_BASE_URL=https://archive.apache.org/dist/pulsar/pulsar-client-cpp-3.5.1
2
- CPP_CLIENT_VERSION=3.5.1
1
+ CPP_CLIENT_BASE_URL=https://archive.apache.org/dist/pulsar/pulsar-client-cpp-3.6.0
2
+ CPP_CLIENT_VERSION=3.6.0
@@ -22,6 +22,8 @@
22
22
  static const std::string PARAM_TLS_CERT = "certificatePath";
23
23
  static const std::string PARAM_TLS_KEY = "privateKeyPath";
24
24
  static const std::string PARAM_TOKEN = "token";
25
+ static const std::string PARAM_USERNAME = "username";
26
+ static const std::string PARAM_PASSWORD = "password";
25
27
 
26
28
  Napi::FunctionReference Authentication::constructor;
27
29
 
@@ -49,7 +51,7 @@ Authentication::Authentication(const Napi::CallbackInfo &info)
49
51
 
50
52
  std::string authMethod = info[0].ToString().Utf8Value();
51
53
 
52
- if (authMethod == "tls" || authMethod == "token") {
54
+ if (authMethod == "tls" || authMethod == "token" || authMethod == "basic") {
53
55
  if (info.Length() < 2 || !info[1].IsObject()) {
54
56
  Napi::Error::New(env, "Authentication parameter must be a object").ThrowAsJavaScriptException();
55
57
  return;
@@ -73,6 +75,15 @@ Authentication::Authentication(const Napi::CallbackInfo &info)
73
75
  }
74
76
  this->cAuthentication =
75
77
  pulsar_authentication_token_create(obj.Get(PARAM_TOKEN).ToString().Utf8Value().c_str());
78
+ } else if (authMethod == "basic") {
79
+ if (!obj.Has(PARAM_USERNAME) || !obj.Get(PARAM_USERNAME).IsString() || !obj.Has(PARAM_PASSWORD) ||
80
+ !obj.Get(PARAM_PASSWORD).IsString()) {
81
+ Napi::Error::New(env, "Missing required parameter").ThrowAsJavaScriptException();
82
+ return;
83
+ }
84
+ this->cAuthentication =
85
+ pulsar_authentication_basic_create(obj.Get(PARAM_USERNAME).ToString().Utf8Value().c_str(),
86
+ obj.Get(PARAM_PASSWORD).ToString().Utf8Value().c_str());
76
87
  }
77
88
  } else if (authMethod == "athenz") {
78
89
  if (info.Length() < 2 || !info[1].IsString()) {
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ const PulsarBinding = require('./pulsar-binding');
20
+
21
+ class AuthenticationBasic {
22
+ constructor(params) {
23
+ this.binding = new PulsarBinding.Authentication('basic', params);
24
+ }
25
+ }
26
+
27
+ module.exports = AuthenticationBasic;
package/tstest.ts CHANGED
@@ -70,6 +70,11 @@ import Pulsar = require('./index');
70
70
  token: 'foobar',
71
71
  });
72
72
 
73
+ const authBasic: Pulsar.AuthenticationBasic = new Pulsar.AuthenticationBasic({
74
+ username: 'basic.username',
75
+ password: 'basic.password',
76
+ });
77
+
73
78
  const client: Pulsar.Client = new Pulsar.Client({
74
79
  serviceUrl: 'pulsar://localhost:6650',
75
80
  authentication: authToken,