pulsar-client 1.5.2 → 1.6.2-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/README.md CHANGED
@@ -54,7 +54,18 @@ If an incompatible version of the C++ client is installed, you may fail to build
54
54
 
55
55
  ### Install on windows
56
56
 
57
- 1. [Build the Pulsar C++ client on windows](https://pulsar.apache.org/docs/en/next/client-libraries-cpp/).
57
+ 1. Build the Pulsar C++ client on windows.
58
+
59
+ ```shell
60
+ cmake \
61
+ -A x64 \
62
+ -DBUILD_PYTHON_WRAPPER=OFF -DBUILD_TESTS=OFF \
63
+ -DVCPKG_TRIPLET=x64-windows \
64
+ -DCMAKE_BUILD_TYPE=Release \
65
+ -S .
66
+ cmake --config Release
67
+ ```
68
+
58
69
 
59
70
  2. Set the variable `PULSAR_CPP_DIR` with the `pulsar-client-cpp` path in a Windows command tool.
60
71
 
@@ -63,6 +74,35 @@ If an incompatible version of the C++ client is installed, you may fail to build
63
74
  set PULSAR_CPP_DIR=C:\pulsar\pulsar-client-cpp
64
75
  ```
65
76
 
77
+ 3. Set the variable `OS_ARCH` in a Windows command tool, `OS_ARCH` is related to the configuration of VCPKG_TRIPLET on the command line above.(Optional)
78
+
79
+ ```shell
80
+ set OS_ARCH=x64-windows
81
+ ```
82
+
83
+ ### Install on mac
84
+
85
+ 1. Install the Pulsar C++ client on mac.
86
+
87
+ ```shell
88
+ brew install libpulsar
89
+ ```
90
+
91
+ 2. Get the installation path of libpulsar
92
+
93
+ ```shell
94
+ brew info libpulsar
95
+ ```
96
+
97
+
98
+ 2. Set the variable `PULSAR_CPP_DIR` with the `pulsar-client-cpp` path in a mac command tool.
99
+
100
+ ```shell
101
+ # for example
102
+ export PULSAR_CPP_DIR=/usr/local/Cellar/libpulsar/2.9.1_1
103
+ ```
104
+
105
+
66
106
  ### Install pulsar-client to your project
67
107
 
68
108
  ```shell
package/binding.gyp CHANGED
@@ -22,7 +22,13 @@
22
22
  ['OS=="win"', {
23
23
  'variables': {
24
24
  'pulsar_cpp_dir%': '<!(echo %PULSAR_CPP_DIR%)',
25
+ 'os_arch%': '<!(echo %OS_ARCH%)',
25
26
  },
27
+ }],
28
+ ['OS=="mac"', {
29
+ 'variables': {
30
+ 'pulsar_cpp_dir': '<!(echo $PULSAR_CPP_DIR)'
31
+ }
26
32
  }]
27
33
  ],
28
34
  "targets": [
@@ -49,12 +55,20 @@
49
55
  "src/ReaderConfig.cc",
50
56
  ],
51
57
  'conditions': [
58
+ ['OS=="mac"', {
59
+ "include_dirs": [
60
+ "<(pulsar_cpp_dir)/include",
61
+ ],
62
+ "libraries": [
63
+ "<(pulsar_cpp_dir)/lib/libpulsar.dylib"
64
+ ],
65
+ }],
52
66
  ['OS=="win"', {
53
67
  "include_dirs": [
54
68
  "<(pulsar_cpp_dir)\include",
55
69
  ],
56
70
  "libraries": [
57
- "-l<(pulsar_cpp_dir)\\build\lib\Release\pulsar.lib"
71
+ "-l<(pulsar_cpp_dir)\\lib\Release\pulsar.lib"
58
72
  ],
59
73
  "dependencies": [
60
74
  "<!(node -p \"require('node-addon-api').gyp\")"
@@ -63,15 +77,15 @@
63
77
  {
64
78
  "destination": "<(PRODUCT_DIR)",
65
79
  "files": [
66
- "<(pulsar_cpp_dir)\\build\lib\Release\pulsar.dll",
67
- "<(pulsar_cpp_dir)\\vcpkg_installed\\x64-windows\\bin\libcurl.dll",
68
- "<(pulsar_cpp_dir)\\vcpkg_installed\\x64-windows\\bin\libprotobuf.dll",
69
- "<(pulsar_cpp_dir)\\vcpkg_installed\\x64-windows\\bin\libssl-1_1-x64.dll",
70
- "<(pulsar_cpp_dir)\\vcpkg_installed\\x64-windows\\bin\libcrypto-1_1-x64.dll",
71
- "<(pulsar_cpp_dir)\\vcpkg_installed\\x64-windows\\bin\dl.dll",
72
- "<(pulsar_cpp_dir)\\vcpkg_installed\\x64-windows\\bin\snappy.dll",
73
- "<(pulsar_cpp_dir)\\vcpkg_installed\\x64-windows\\bin\zlib1.dll",
74
- "<(pulsar_cpp_dir)\\vcpkg_installed\\x64-windows\\bin\zstd.dll",
80
+ "<(pulsar_cpp_dir)\\lib\Release\pulsar.dll",
81
+ "<(pulsar_cpp_dir)\\vcpkg_installed\\<(os_arch)\\bin\libcurl.dll",
82
+ "<(pulsar_cpp_dir)\\vcpkg_installed\\<(os_arch)\\bin\libprotobuf.dll",
83
+ "<(pulsar_cpp_dir)\\vcpkg_installed\\<(os_arch)\\bin\libssl-1_1-x64.dll",
84
+ "<(pulsar_cpp_dir)\\vcpkg_installed\\<(os_arch)\\bin\libcrypto-1_1-x64.dll",
85
+ "<(pulsar_cpp_dir)\\vcpkg_installed\\<(os_arch)\\bin\dl.dll",
86
+ "<(pulsar_cpp_dir)\\vcpkg_installed\\<(os_arch)\\bin\snappy.dll",
87
+ "<(pulsar_cpp_dir)\\vcpkg_installed\\<(os_arch)\\bin\zlib1.dll",
88
+ "<(pulsar_cpp_dir)\\vcpkg_installed\\<(os_arch)\\bin\zstd.dll",
75
89
  ]
76
90
  }
77
91
  ]
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;
23
+ authentication?: AuthenticationTls | AuthenticationAthenz | AuthenticationToken | AuthenticationOauth2;
24
24
  operationTimeoutSeconds?: number;
25
25
  ioThreads?: number;
26
26
  messageListenerThreads?: number;
@@ -175,6 +175,18 @@ export class AuthenticationToken {
175
175
  constructor(params: { token: string });
176
176
  }
177
177
 
178
+ export class AuthenticationOauth2 {
179
+ constructor(params: {
180
+ type: string;
181
+ issuer_url: string;
182
+ client_id?: string;
183
+ client_secret?: string;
184
+ private_key?: string;
185
+ audience?: string;
186
+ scope?: string;
187
+ });
188
+ }
189
+
178
190
  export enum LogLevel {
179
191
  DEBUG = 0,
180
192
  INFO = 1,
package/index.js CHANGED
@@ -21,6 +21,7 @@ const PulsarBinding = require('bindings')('Pulsar');
21
21
  const AuthenticationTls = require('./src/AuthenticationTls.js');
22
22
  const AuthenticationAthenz = require('./src/AuthenticationAthenz.js');
23
23
  const AuthenticationToken = require('./src/AuthenticationToken.js');
24
+ const AuthenticationOauth2 = require('./src/AuthenticationOauth2.js');
24
25
 
25
26
  const LogLevel = {
26
27
  DEBUG: 0,
@@ -36,6 +37,7 @@ const Pulsar = {
36
37
  AuthenticationTls,
37
38
  AuthenticationAthenz,
38
39
  AuthenticationToken,
40
+ AuthenticationOauth2,
39
41
  LogLevel,
40
42
  };
41
43
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pulsar-client",
3
- "version": "1.5.2",
3
+ "version": "1.6.2-rc.1",
4
4
  "description": "Pulsar Node.js client",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -76,7 +76,8 @@
76
76
  "file_types": [
77
77
  ".json",
78
78
  ".pem",
79
- ".txt"
79
+ ".txt",
80
+ ".gz"
80
81
  ],
81
82
  "trailing_whitespace": "TRIM",
82
83
  "insert_license": true,
@@ -80,6 +80,13 @@ Authentication::Authentication(const Napi::CallbackInfo &info)
80
80
  return;
81
81
  }
82
82
  this->cAuthentication = pulsar_authentication_athenz_create(info[1].ToString().Utf8Value().c_str());
83
+ } else if (authMethod == "oauth2") {
84
+ if (info.Length() < 2 || !info[1].IsString()) {
85
+ Napi::Error::New(env, "Authentication parameter must be a JSON string for oauth2")
86
+ .ThrowAsJavaScriptException();
87
+ return;
88
+ }
89
+ this->cAuthentication = pulsar_authentication_oauth2_create(info[1].ToString().Utf8Value().c_str());
83
90
  } else {
84
91
  Napi::Error::New(env, "Unsupported authentication method").ThrowAsJavaScriptException();
85
92
  return;
@@ -0,0 +1,28 @@
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('bindings')('Pulsar');
20
+
21
+ class AuthenticationOauth2 {
22
+ constructor(params) {
23
+ const paramsStr = (typeof params === 'object') ? JSON.stringify(params) : params;
24
+ this.binding = new PulsarBinding.Authentication('oauth2', paramsStr);
25
+ }
26
+ }
27
+
28
+ module.exports = AuthenticationOauth2;
package/tstest.ts CHANGED
@@ -39,6 +39,23 @@ import Pulsar = require('./index');
39
39
  tokenExpirationTime: '3600',
40
40
  });
41
41
 
42
+ const authOauth2PrivateKey: Pulsar.AuthenticationOauth2 = new Pulsar.AuthenticationOauth2({
43
+ type: "client_credentials",
44
+ issuer_url: "issuer-url",
45
+ private_key: "credentials-file-path",
46
+ audience: "audience",
47
+ scope: "your-scope",
48
+ });
49
+
50
+ const authOauth2ClientId: Pulsar.AuthenticationOauth2 = new Pulsar.AuthenticationOauth2({
51
+ type: "client_credentials",
52
+ issuer_url: "issuer-url",
53
+ client_id: "client-id",
54
+ client_secret: "client-secret",
55
+ audience: "audience",
56
+ scope: "scope"
57
+ });
58
+
42
59
  const authToken: Pulsar.AuthenticationToken = new Pulsar.AuthenticationToken({
43
60
  token: 'foobar',
44
61
  });