pulsar-client 1.5.0 → 1.6.0

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,17 @@ 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
+ ```
58
68
 
59
69
  2. Set the variable `PULSAR_CPP_DIR` with the `pulsar-client-cpp` path in a Windows command tool.
60
70
 
@@ -63,6 +73,13 @@ If an incompatible version of the C++ client is installed, you may fail to build
63
73
  set PULSAR_CPP_DIR=C:\pulsar\pulsar-client-cpp
64
74
  ```
65
75
 
76
+ 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)
77
+
78
+ ```shell
79
+ set OS_ARCH=x64-windows
80
+ ```
81
+
82
+
66
83
  ### Install pulsar-client to your project
67
84
 
68
85
  ```shell
package/binding.gyp CHANGED
@@ -22,6 +22,7 @@
22
22
  ['OS=="win"', {
23
23
  'variables': {
24
24
  'pulsar_cpp_dir%': '<!(echo %PULSAR_CPP_DIR%)',
25
+ 'os_arch%': '<!(echo %OS_ARCH%)',
25
26
  },
26
27
  }]
27
28
  ],
@@ -54,7 +55,7 @@
54
55
  "<(pulsar_cpp_dir)\include",
55
56
  ],
56
57
  "libraries": [
57
- "-l<(pulsar_cpp_dir)\\build\lib\Release\pulsar.lib"
58
+ "-l<(pulsar_cpp_dir)\\lib\Release\pulsar.lib"
58
59
  ],
59
60
  "dependencies": [
60
61
  "<!(node -p \"require('node-addon-api').gyp\")"
@@ -63,15 +64,15 @@
63
64
  {
64
65
  "destination": "<(PRODUCT_DIR)",
65
66
  "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",
67
+ "<(pulsar_cpp_dir)\\lib\Release\pulsar.dll",
68
+ "<(pulsar_cpp_dir)\\vcpkg_installed\\<(os_arch)\\bin\libcurl.dll",
69
+ "<(pulsar_cpp_dir)\\vcpkg_installed\\<(os_arch)\\bin\libprotobuf.dll",
70
+ "<(pulsar_cpp_dir)\\vcpkg_installed\\<(os_arch)\\bin\libssl-1_1-x64.dll",
71
+ "<(pulsar_cpp_dir)\\vcpkg_installed\\<(os_arch)\\bin\libcrypto-1_1-x64.dll",
72
+ "<(pulsar_cpp_dir)\\vcpkg_installed\\<(os_arch)\\bin\dl.dll",
73
+ "<(pulsar_cpp_dir)\\vcpkg_installed\\<(os_arch)\\bin\snappy.dll",
74
+ "<(pulsar_cpp_dir)\\vcpkg_installed\\<(os_arch)\\bin\zlib1.dll",
75
+ "<(pulsar_cpp_dir)\\vcpkg_installed\\<(os_arch)\\bin\zstd.dll",
75
76
  ]
76
77
  }
77
78
  ]
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.0",
3
+ "version": "1.6.0",
4
4
  "description": "Pulsar Node.js client",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -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
  });