This is an automated email from the ASF dual-hosted git repository.

nkurihar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-client-node.git


The following commit(s) were added to refs/heads/master by this push:
     new d074ca5  Add type definitions for properties related to E2E encryption 
(#150)
d074ca5 is described below

commit d074ca511c0eac28ac20bbb3f9daf86cdbd34453
Author: Masahiro Sakamoto <[email protected]>
AuthorDate: Fri Apr 16 14:27:10 2021 +0900

    Add type definitions for properties related to E2E encryption (#150)
---
 index.d.ts | 14 ++++++++++++++
 tstest.ts  |  8 ++++++++
 2 files changed, 22 insertions(+)

diff --git a/index.d.ts b/index.d.ts
index 44e5342..7e57d74 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -56,6 +56,9 @@ export interface ProducerConfig {
   batchingMaxPublishDelayMs?: number;
   batchingMaxMessages?: number;
   properties?: { [key: string]: string };
+  publicKeyPath?: string;
+  encryptionKey?: string;
+  cryptoFailureAction?: ProducerCryptoFailureAction;
 }
 
 export class Producer {
@@ -81,6 +84,8 @@ export interface ConsumerConfig {
   properties?: { [key: string]: string };
   listener?: (message: Message, consumer: Consumer) => void;
   readCompacted?: boolean;
+  privateKeyPath?: string;
+  cryptoFailureAction?: ConsumerCryptoFailureAction;
 }
 
 export class Consumer {
@@ -187,6 +192,10 @@ export type CompressionType =
   'ZSTD' |
   'SNAPPY';
 
+export type ProducerCryptoFailureAction =
+  'FAIL' |
+  'SEND';
+
 export type SubscriptionType =
   'Exclusive' |
   'Shared' |
@@ -196,3 +205,8 @@ export type SubscriptionType =
 export type InitialPosition =
   'Latest' |
   'Earliest';
+
+export type ConsumerCryptoFailureAction =
+  'FAIL' |
+  'DISCARD' |
+  'CONSUME';
diff --git a/tstest.ts b/tstest.ts
index ca2cbbc..dfa2a3d 100644
--- a/tstest.ts
+++ b/tstest.ts
@@ -91,6 +91,9 @@ import Pulsar = require('./index');
       key1: 'value1',
       key2: 'value2',
     },
+    publicKeyPath: '/path/to/public.key',
+    encryptionKey: 'encryption-key',
+    cryptoFailureAction: 'FAIL',
   });
 
   const producer2: Pulsar.Producer = await client.createProducer({
@@ -98,6 +101,7 @@ import Pulsar = require('./index');
     messageRoutingMode: 'RoundRobinDistribution',
     hashingScheme: 'BoostHash',
     compressionType: 'LZ4',
+    cryptoFailureAction: 'SEND',
   });
 
   const producer3: Pulsar.Producer = await client.createProducer({
@@ -127,6 +131,8 @@ import Pulsar = require('./index');
       key2: 'value2',
     },
     readCompacted: false,
+    privateKeyPath: '/path/to/private.key',
+    cryptoFailureAction: 'FAIL',
   });
 
   const consumer2: Pulsar.Consumer = await client.subscribe({
@@ -134,6 +140,7 @@ import Pulsar = require('./index');
     subscription: 'my-sub2',
     subscriptionType: 'Shared',
     subscriptionInitialPosition: 'Earliest',
+    cryptoFailureAction: 'DISCARD',
   });
 
   const consumer3: Pulsar.Consumer = await client.subscribe({
@@ -142,6 +149,7 @@ import Pulsar = require('./index');
     subscriptionType: 'KeyShared',
     listener: (message: Pulsar.Message, consumer: Pulsar.Consumer) => {
     },
+    cryptoFailureAction: 'CONSUME',
   });
 
   const consumer4: Pulsar.Consumer = await client.subscribe({

Reply via email to