splp-nodejs 1.0.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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +35 -0
  3. package/dist/config/index.d.ts +139 -0
  4. package/dist/config/index.d.ts.map +1 -0
  5. package/dist/config/index.js +258 -0
  6. package/dist/config/index.js.map +1 -0
  7. package/dist/lib/crypto/json-encryptor.d.ts +149 -0
  8. package/dist/lib/crypto/json-encryptor.d.ts.map +1 -0
  9. package/dist/lib/crypto/json-encryptor.js +568 -0
  10. package/dist/lib/crypto/json-encryptor.js.map +1 -0
  11. package/dist/lib/index.d.ts +18 -0
  12. package/dist/lib/index.d.ts.map +1 -0
  13. package/dist/lib/index.js +18 -0
  14. package/dist/lib/index.js.map +1 -0
  15. package/dist/lib/kafka/kafka-wrapper.d.ts +27 -0
  16. package/dist/lib/kafka/kafka-wrapper.d.ts.map +1 -0
  17. package/dist/lib/kafka/kafka-wrapper.js +206 -0
  18. package/dist/lib/kafka/kafka-wrapper.js.map +1 -0
  19. package/dist/lib/tracing/tracer.d.ts +19 -0
  20. package/dist/lib/tracing/tracer.d.ts.map +1 -0
  21. package/dist/lib/tracing/tracer.js +147 -0
  22. package/dist/lib/tracing/tracer.js.map +1 -0
  23. package/dist/lib/utils/circuit-breaker.d.ts +27 -0
  24. package/dist/lib/utils/circuit-breaker.d.ts.map +1 -0
  25. package/dist/lib/utils/circuit-breaker.js +56 -0
  26. package/dist/lib/utils/circuit-breaker.js.map +1 -0
  27. package/dist/lib/utils/request-id.d.ts +3 -0
  28. package/dist/lib/utils/request-id.d.ts.map +1 -0
  29. package/dist/lib/utils/request-id.js +9 -0
  30. package/dist/lib/utils/request-id.js.map +1 -0
  31. package/dist/lib/utils/retry-manager.d.ts +42 -0
  32. package/dist/lib/utils/retry-manager.d.ts.map +1 -0
  33. package/dist/lib/utils/retry-manager.js +69 -0
  34. package/dist/lib/utils/retry-manager.js.map +1 -0
  35. package/dist/lib/utils/sanitizer.d.ts +32 -0
  36. package/dist/lib/utils/sanitizer.d.ts.map +1 -0
  37. package/dist/lib/utils/sanitizer.js +235 -0
  38. package/dist/lib/utils/sanitizer.js.map +1 -0
  39. package/dist/types/index.d.ts +115 -0
  40. package/dist/types/index.d.ts.map +1 -0
  41. package/dist/types/index.js +2 -0
  42. package/dist/types/index.js.map +1 -0
  43. package/package.json +61 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Muhammad Zuhri
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # splp-nodejs
2
+
3
+ SPLP Node.js is a Node.js library for Government Service Integration. It provides robust tools for working with Kafka, payload encryption/decryption, request tracing (via OpenTelemetry), and built-in error handling like Circuit Breakers and Retry Managers.
4
+
5
+ ## Features
6
+
7
+ - **Kafka Wrapper**: Easy connection, consuming, and producing to Kafka.
8
+ - **Payload Encryption**: Highly secure `JsonEncryptor` to easily encrypt and decrypt JSON data for communication.
9
+ - **Tracing**: Built-in OpenTelemetry tracing utilities (`initTracing`, `getTracer`, `withSpan`, etc.).
10
+ - **Security**: Prevent XSS and Injection, sanitize objects, validate inputs securely.
11
+ - **Resilience**: Integrated `CircuitBreaker` and `RetryManager` for robust microservices.
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install splp-nodejs
17
+ ```
18
+
19
+ ## Basic Usage
20
+
21
+ ### Importing
22
+ You can simply import what you need directly from the package:
23
+
24
+ ```ts
25
+ import {
26
+ KafkaWrapper,
27
+ JsonEncryptor,
28
+ initTracing,
29
+ CircuitBreaker
30
+ } from 'splp-nodejs';
31
+ ```
32
+
33
+ ## License
34
+
35
+ MIT
@@ -0,0 +1,139 @@
1
+ /**
2
+ * SPLP Configuration
3
+ *
4
+ * Edit this file to configure your service.
5
+ * All configuration options are centralized here for easy management.
6
+ */
7
+ /**
8
+ * Kafka broker addresses (comma-separated for multiple brokers)
9
+ * Examples:
10
+ * - Local: 'localhost:9092'
11
+ * - Remote: 'splp-kafka.layanan.go.id:443'
12
+ * - Multiple: 'broker1:9092,broker2:9092,broker3:9092'
13
+ */
14
+ export declare const KAFKA_HOSTS: string;
15
+ /**
16
+ * Kafka client configuration
17
+ */
18
+ export declare const KAFKA_CONFIG: {
19
+ brokers: string[];
20
+ clientId: string;
21
+ groupId: string;
22
+ inboxTopic: string;
23
+ connectionTimeout: number;
24
+ requestTimeout: number;
25
+ socketTimeout: number;
26
+ sessionTimeout: number;
27
+ heartbeatInterval: number;
28
+ rebalanceTimeout: number;
29
+ maxRequestSize: number;
30
+ maxBytes: number;
31
+ fetchMaxBytes: number;
32
+ maxMessageBytes: number;
33
+ };
34
+ /**
35
+ * Path to certificates directory
36
+ */
37
+ export declare const CERTS_PATH: string;
38
+ /**
39
+ * Kafka SSL/mTLS configuration
40
+ */
41
+ export declare const KAFKA_SSL_CONFIG: {
42
+ enabled: boolean;
43
+ rejectUnauthorized: boolean;
44
+ caPath: string;
45
+ certPath: string;
46
+ keyPath: string;
47
+ };
48
+ /**
49
+ * Seal API SSL/mTLS configuration
50
+ */
51
+ export declare const SEAL_SSL_CONFIG: {
52
+ rejectUnauthorized: boolean;
53
+ clientCertPath: string;
54
+ clientKeyPath: string;
55
+ caPath: string;
56
+ };
57
+ /**
58
+ * Seal API endpoint for encryption/decryption
59
+ */
60
+ export declare const SEAL_API_URL: string;
61
+ /**
62
+ * Seal API timeout (milliseconds)
63
+ */
64
+ export declare const SEAL_API_TIMEOUT: number;
65
+ /**
66
+ * Public key for encryption (PEM format)
67
+ * Can be overridden via environment variable PUBLIC_KEY
68
+ */
69
+ export declare const PUBLIC_KEYS: string[];
70
+ /**
71
+ * Request ID prefix for encryption operations
72
+ */
73
+ export declare const REQUEST_ID_PREFIX: string;
74
+ /**
75
+ * Service name for tracing
76
+ */
77
+ export declare const SERVICE_NAME: string;
78
+ /**
79
+ * Tempo/OpenTelemetry endpoint
80
+ */
81
+ export declare const TEMPO_ENDPOINT: string;
82
+ /**
83
+ * Enable/disable tracing
84
+ */
85
+ export declare const TRACING_ENABLED: boolean;
86
+ /**
87
+ * Maximum concurrent message processing
88
+ */
89
+ export declare const MAX_CONCURRENT_MESSAGES: number;
90
+ /**
91
+ * Instance ID for load balancing (auto-generated if not set)
92
+ */
93
+ export declare const INSTANCE_ID: string;
94
+ /**
95
+ * Enable verbose logging
96
+ */
97
+ export declare const VERBOSE_LOGS: boolean;
98
+ /**
99
+ * Enable encryption logging
100
+ */
101
+ export declare const ENABLE_ENCRYPTION_LOGGING: boolean;
102
+ export declare const SANITIZER_CONFIG: {
103
+ maxStringLength: number;
104
+ maxObjectDepth: number;
105
+ maxArrayLength: number;
106
+ strictMode: boolean;
107
+ };
108
+ /**
109
+ * Check if using local Kafka broker
110
+ */
111
+ export declare function isLocalBroker(): boolean;
112
+ /**
113
+ * Get full Kafka configuration with SSL
114
+ */
115
+ export declare function getKafkaConfig(): any;
116
+ /**
117
+ * Get Seal API / JsonEncryptor configuration
118
+ */
119
+ export declare function getEncryptorConfig(): {
120
+ apiBaseUrl: string;
121
+ publicKeys: string[];
122
+ apiTimeout: number;
123
+ tlsConfig: any;
124
+ requestIdPrefix: string;
125
+ enableLogging: boolean;
126
+ };
127
+ /**
128
+ * Get tracing configuration
129
+ */
130
+ export declare function getTracingConfig(): {
131
+ serviceName: string;
132
+ tempoEndpoint: string;
133
+ enabled: boolean;
134
+ };
135
+ /**
136
+ * Print current configuration (for debugging)
137
+ */
138
+ export declare function printConfig(): void;
139
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../config/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,QAA4D,CAAC;AAErF;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;CA0BxB,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,UAAU,QAA2D,CAAC;AAEnF;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;CAQ5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;CAO3B,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,YAAY,QAA6D,CAAC;AAEvF;;GAEG;AACH,eAAO,MAAM,gBAAgB,QAAoD,CAAC;AAElF;;;GAGG;AAMH,eAAO,MAAM,WAAW,EAAE,MAAM,EAE/B,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAA0C,CAAC;AAMzE;;GAEG;AACH,eAAO,MAAM,YAAY,QAAgD,CAAC;AAE1E;;GAEG;AACH,eAAO,MAAM,cAAc,QAAiF,CAAC;AAE7G;;GAEG;AACH,eAAO,MAAM,eAAe,SAA0C,CAAC;AAMvE;;GAEG;AACH,eAAO,MAAM,uBAAuB,QAAwD,CAAC;AAE7F;;GAEG;AACH,eAAO,MAAM,WAAW,QAAqE,CAAC;AAE9F;;GAEG;AACH,eAAO,MAAM,YAAY,SAAsC,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,yBAAyB,SAAmD,CAAC;AAM1F,eAAO,MAAM,gBAAgB;;;;;CAK5B,CAAC;AAMF;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAIvC;AAED;;GAEG;AACH,wBAAgB,cAAc,QAkC7B;AAED;;GAEG;AACH,wBAAgB,kBAAkB;;;;;;;EAqBjC;AAED;;GAEG;AACH,wBAAgB,gBAAgB;;;;EAM/B;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,IAAI,CA8BlC"}
@@ -0,0 +1,258 @@
1
+ /**
2
+ * SPLP Configuration
3
+ *
4
+ * Edit this file to configure your service.
5
+ * All configuration options are centralized here for easy management.
6
+ */
7
+ import { fileURLToPath } from 'url';
8
+ import { dirname, join } from 'path';
9
+ import { readFileSync, existsSync } from 'fs';
10
+ const __dirname = dirname(fileURLToPath(import.meta.url));
11
+ // =============================================================================
12
+ // KAFKA CONFIGURATION
13
+ // =============================================================================
14
+ /**
15
+ * Kafka broker addresses (comma-separated for multiple brokers)
16
+ * Examples:
17
+ * - Local: 'localhost:9092'
18
+ * - Remote: 'splp-kafka.layanan.go.id:443'
19
+ * - Multiple: 'broker1:9092,broker2:9092,broker3:9092'
20
+ */
21
+ export const KAFKA_HOSTS = process.env.KAFKA_HOSTS || 'splp-kafka.layanan.go.id:443';
22
+ /**
23
+ * Kafka client configuration
24
+ */
25
+ export const KAFKA_CONFIG = {
26
+ // Broker addresses (parsed from KAFKA_HOSTS)
27
+ brokers: KAFKA_HOSTS.split(',').map(b => b.trim()),
28
+ // Client identification
29
+ clientId: process.env.KAFKA_CLIENT_ID || 'splp-service',
30
+ groupId: process.env.KAFKA_GROUP_ID || 'splp-consumer-group',
31
+ // Topics
32
+ inboxTopic: process.env.KAFKA_INBOX_TOPIC || 'splp-inbox',
33
+ // Connection timeouts (milliseconds)
34
+ connectionTimeout: parseInt(process.env.KAFKA_CONNECTION_TIMEOUT || '30000'),
35
+ requestTimeout: parseInt(process.env.KAFKA_REQUEST_TIMEOUT || '60000'),
36
+ socketTimeout: parseInt(process.env.KAFKA_SOCKET_TIMEOUT || '60000'),
37
+ // Consumer settings
38
+ sessionTimeout: parseInt(process.env.KAFKA_SESSION_TIMEOUT || '60000'),
39
+ heartbeatInterval: parseInt(process.env.KAFKA_HEARTBEAT_INTERVAL || '5000'),
40
+ rebalanceTimeout: parseInt(process.env.KAFKA_REBALANCE_TIMEOUT || '120000'),
41
+ // Message size limits (bytes)
42
+ maxRequestSize: parseInt(process.env.KAFKA_MAX_REQUEST_SIZE || '10485760'), // 10MB
43
+ maxBytes: parseInt(process.env.KAFKA_MAX_BYTES || '10485760'), // 10MB
44
+ fetchMaxBytes: parseInt(process.env.KAFKA_FETCH_MAX_BYTES || '52428800'), // 50MB
45
+ maxMessageBytes: parseInt(process.env.KAFKA_MAX_MESSAGE_BYTES || '10485760'), // 10MB
46
+ };
47
+ // =============================================================================
48
+ // SSL/TLS CERTIFICATES CONFIGURATION
49
+ // =============================================================================
50
+ /**
51
+ * Path to certificates directory
52
+ */
53
+ export const CERTS_PATH = process.env.CERTS_PATH || join(__dirname, '..', 'certs');
54
+ /**
55
+ * Kafka SSL/mTLS configuration
56
+ */
57
+ export const KAFKA_SSL_CONFIG = {
58
+ enabled: process.env.KAFKA_SSL_ENABLED !== 'false',
59
+ rejectUnauthorized: process.env.KAFKA_SSL_REJECT_UNAUTHORIZED !== 'false',
60
+ // Certificate paths
61
+ caPath: process.env.KAFKA_CA_PATH || join(CERTS_PATH, 'kafka', 'ca.pem'),
62
+ certPath: process.env.KAFKA_CERT_PATH || join(CERTS_PATH, 'kafka', 'client.crt'),
63
+ keyPath: process.env.KAFKA_KEY_PATH || join(CERTS_PATH, 'kafka', 'client.key'),
64
+ };
65
+ /**
66
+ * Seal API SSL/mTLS configuration
67
+ */
68
+ export const SEAL_SSL_CONFIG = {
69
+ rejectUnauthorized: process.env.SEAL_SSL_REJECT_UNAUTHORIZED === 'true', // Default: false
70
+ // Certificate paths
71
+ clientCertPath: process.env.SEAL_CLIENT_CERT_PATH || join(CERTS_PATH, 'seal', 'client.crt'),
72
+ clientKeyPath: process.env.SEAL_CLIENT_KEY_PATH || join(CERTS_PATH, 'seal', 'client.key'),
73
+ caPath: process.env.SEAL_CA_PATH || join(CERTS_PATH, 'seal', 'ca.pem'),
74
+ };
75
+ // =============================================================================
76
+ // SEAL API / ENCRYPTION CONFIGURATION
77
+ // =============================================================================
78
+ /**
79
+ * Seal API endpoint for encryption/decryption
80
+ */
81
+ export const SEAL_API_URL = process.env.SEAL_API_URL || 'https://192.168.112.153:2798';
82
+ /**
83
+ * Seal API timeout (milliseconds)
84
+ */
85
+ export const SEAL_API_TIMEOUT = parseInt(process.env.SEAL_API_TIMEOUT || '30000');
86
+ /**
87
+ * Public key for encryption (PEM format)
88
+ * Can be overridden via environment variable PUBLIC_KEY
89
+ */
90
+ // export const PUBLIC_KEYS: string[] = process.env.PUBLIC_KEY
91
+ // ? [process.env.PUBLIC_KEY]
92
+ // : ["-----BEGIN PUBLIC KEY-----\nMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAsZETxaoX2xeL+YZXijZr\nqCRgg7KgdNYB5fmpIo7ldgKmTa2EGC3BYTxCkN/W9iUnuXECxjYw8S7r5lTXX7rF\nbNXab6D53bgxrq1FDf1CzAvIPe2QdgomA2k+6ZWSQ9gFZior6BWnDOj8rNfzCs88\n+ZNz7PWBIfuKoMXC9RnPaVnxGyJv+k8/DKwWmvJjEotezgOb5b/CyCu2kokGy1kj\nxG4WHToi/9dGC2+RVZwhz82mwUqEr4NWTTrBuDKtepEEEyQ8LpfoWqADBMm8V5QX\neR99cAJTbKTMRjgRkdwW23Zw8/TuAXipqCk+2b07l9wpNX4WnL7b6hkJAh79F3gm\npifL6dXzSLundKLRcAMOKcspqzbDYZDU8BfHowIQhULkiT9nHkYAFxobqGZP4N1L\nYcFn0dLxbmfdc1ZcreimFlkuZtfBpVouMeX9ftOgbFa/XGy3IHLu0RElLpWsnj4u\nbMCjUZjBocKdirqIV/NYlashds22oTrFaWO5fGDPnZ7fAgMBAAE=\n-----END PUBLIC KEY-----"];
93
+ export const PUBLIC_KEYS = [
94
+ `-----BEGIN PUBLIC KEY-----\nMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAsZETxaoX2xeL+YZXijZr\nqCRgg7KgdNYB5fmpIo7ldgKmTa2EGC3BYTxCkN/W9iUnuXECxjYw8S7r5lTXX7rF\nbNXab6D53bgxrq1FDf1CzAvIPe2QdgomA2k+6ZWSQ9gFZior6BWnDOj8rNfzCs88\n+ZNz7PWBIfuKoMXC9RnPaVnxGyJv+k8/DKwWmvJjEotezgOb5b/CyCu2kokGy1kj\nxG4WHToi/9dGC2+RVZwhz82mwUqEr4NWTTrBuDKtepEEEyQ8LpfoWqADBMm8V5QX\neR99cAJTbKTMRjgRkdwW23Zw8/TuAXipqCk+2b07l9wpNX4WnL7b6hkJAh79F3gm\npifL6dXzSLundKLRcAMOKcspqzbDYZDU8BfHowIQhULkiT9nHkYAFxobqGZP4N1L\nYcFn0dLxbmfdc1ZcreimFlkuZtfBpVouMeX9ftOgbFa/XGy3IHLu0RElLpWsnj4u\nbMCjUZjBocKdirqIV/NYlashds22oTrFaWO5fGDPnZ7fAgMBAAE=\n-----END PUBLIC KEY-----\n`,
95
+ ];
96
+ /**
97
+ * Request ID prefix for encryption operations
98
+ */
99
+ export const REQUEST_ID_PREFIX = process.env.REQUEST_ID_PREFIX || 'splp';
100
+ // =============================================================================
101
+ // TRACING CONFIGURATION (OpenTelemetry / Tempo)
102
+ // =============================================================================
103
+ /**
104
+ * Service name for tracing
105
+ */
106
+ export const SERVICE_NAME = process.env.SERVICE_NAME || 'service_testing';
107
+ /**
108
+ * Tempo/OpenTelemetry endpoint
109
+ */
110
+ export const TEMPO_ENDPOINT = process.env.TEMPO_ENDPOINT || 'http://splp-tempo-http.layanan.go.id/v1/traces';
111
+ /**
112
+ * Enable/disable tracing
113
+ */
114
+ export const TRACING_ENABLED = process.env.TRACING_ENABLED !== 'false';
115
+ // =============================================================================
116
+ // PROCESSING CONFIGURATION
117
+ // =============================================================================
118
+ /**
119
+ * Maximum concurrent message processing
120
+ */
121
+ export const MAX_CONCURRENT_MESSAGES = parseInt(process.env.MAX_CONCURRENT_MESSAGES || '25');
122
+ /**
123
+ * Instance ID for load balancing (auto-generated if not set)
124
+ */
125
+ export const INSTANCE_ID = process.env.INSTANCE_ID || Math.random().toString(36).substring(7);
126
+ /**
127
+ * Enable verbose logging
128
+ */
129
+ export const VERBOSE_LOGS = process.env.VERBOSE_LOGS === 'true';
130
+ /**
131
+ * Enable encryption logging
132
+ */
133
+ export const ENABLE_ENCRYPTION_LOGGING = process.env.ENABLE_ENCRYPTION_LOGGING === 'true';
134
+ // =============================================================================
135
+ // SANITIZATION CONFIGURATION
136
+ // =============================================================================
137
+ export const SANITIZER_CONFIG = {
138
+ maxStringLength: parseInt(process.env.SANITIZER_MAX_STRING_LENGTH || '2000'),
139
+ maxObjectDepth: parseInt(process.env.SANITIZER_MAX_OBJECT_DEPTH || '5'),
140
+ maxArrayLength: parseInt(process.env.SANITIZER_MAX_ARRAY_LENGTH || '1000'),
141
+ strictMode: process.env.SANITIZER_STRICT_MODE === 'true',
142
+ };
143
+ // =============================================================================
144
+ // HELPER FUNCTIONS
145
+ // =============================================================================
146
+ /**
147
+ * Check if using local Kafka broker
148
+ */
149
+ export function isLocalBroker() {
150
+ const brokers = KAFKA_CONFIG.brokers;
151
+ return brokers.length === 1 &&
152
+ (brokers[0] === 'localhost:9092' || brokers[0].startsWith('127.0.0.1:'));
153
+ }
154
+ /**
155
+ * Get full Kafka configuration with SSL
156
+ */
157
+ export function getKafkaConfig() {
158
+ const config = {
159
+ brokers: KAFKA_CONFIG.brokers,
160
+ clientId: `${KAFKA_CONFIG.clientId}-${INSTANCE_ID}`,
161
+ groupId: KAFKA_CONFIG.groupId,
162
+ connectionTimeout: KAFKA_CONFIG.connectionTimeout,
163
+ requestTimeout: KAFKA_CONFIG.requestTimeout,
164
+ socketTimeout: KAFKA_CONFIG.socketTimeout,
165
+ sessionTimeout: KAFKA_CONFIG.sessionTimeout,
166
+ heartbeatInterval: KAFKA_CONFIG.heartbeatInterval,
167
+ rebalanceTimeout: KAFKA_CONFIG.rebalanceTimeout,
168
+ maxRequestSize: KAFKA_CONFIG.maxRequestSize,
169
+ maxBytes: KAFKA_CONFIG.maxBytes,
170
+ fetchMaxBytes: KAFKA_CONFIG.fetchMaxBytes,
171
+ maxMessageBytes: KAFKA_CONFIG.maxMessageBytes,
172
+ };
173
+ // Add SSL configuration for remote brokers
174
+ if (!isLocalBroker() && KAFKA_SSL_CONFIG.enabled) {
175
+ if (existsSync(KAFKA_SSL_CONFIG.caPath) &&
176
+ existsSync(KAFKA_SSL_CONFIG.certPath) &&
177
+ existsSync(KAFKA_SSL_CONFIG.keyPath)) {
178
+ config.ssl = {
179
+ rejectUnauthorized: KAFKA_SSL_CONFIG.rejectUnauthorized,
180
+ ca: [readFileSync(KAFKA_SSL_CONFIG.caPath)],
181
+ cert: readFileSync(KAFKA_SSL_CONFIG.certPath),
182
+ key: readFileSync(KAFKA_SSL_CONFIG.keyPath),
183
+ };
184
+ }
185
+ else {
186
+ console.warn('Warning: Kafka SSL certificates not found, running without SSL');
187
+ }
188
+ }
189
+ return config;
190
+ }
191
+ /**
192
+ * Get Seal API / JsonEncryptor configuration
193
+ */
194
+ export function getEncryptorConfig() {
195
+ // Only include caPath if the file exists (like the working kemensos version)
196
+ const tlsConfig = {
197
+ clientCertPath: SEAL_SSL_CONFIG.clientCertPath,
198
+ clientKeyPath: SEAL_SSL_CONFIG.clientKeyPath,
199
+ rejectUnauthorized: SEAL_SSL_CONFIG.rejectUnauthorized,
200
+ };
201
+ // Only add caPath if CA file exists
202
+ if (existsSync(SEAL_SSL_CONFIG.caPath)) {
203
+ tlsConfig.caPath = SEAL_SSL_CONFIG.caPath;
204
+ }
205
+ return {
206
+ apiBaseUrl: SEAL_API_URL,
207
+ publicKeys: PUBLIC_KEYS,
208
+ apiTimeout: SEAL_API_TIMEOUT,
209
+ tlsConfig,
210
+ requestIdPrefix: REQUEST_ID_PREFIX,
211
+ enableLogging: ENABLE_ENCRYPTION_LOGGING, // Default: false, set ENABLE_ENCRYPTION_LOGGING=true to enable
212
+ };
213
+ }
214
+ /**
215
+ * Get tracing configuration
216
+ */
217
+ export function getTracingConfig() {
218
+ return {
219
+ serviceName: SERVICE_NAME,
220
+ tempoEndpoint: TEMPO_ENDPOINT,
221
+ enabled: TRACING_ENABLED,
222
+ };
223
+ }
224
+ /**
225
+ * Print current configuration (for debugging)
226
+ */
227
+ export function printConfig() {
228
+ console.log('');
229
+ console.log('='.repeat(60));
230
+ console.log('SPLP Configuration');
231
+ console.log('='.repeat(60));
232
+ console.log('');
233
+ console.log('Kafka:');
234
+ console.log(` Hosts: ${KAFKA_HOSTS}`);
235
+ console.log(` Client ID: ${KAFKA_CONFIG.clientId}-${INSTANCE_ID}`);
236
+ console.log(` Group ID: ${KAFKA_CONFIG.groupId}`);
237
+ console.log(` Inbox Topic: ${KAFKA_CONFIG.inboxTopic}`);
238
+ console.log(` SSL Enabled: ${KAFKA_SSL_CONFIG.enabled && !isLocalBroker()}`);
239
+ console.log('');
240
+ console.log('Seal API:');
241
+ console.log(` URL: ${SEAL_API_URL}`);
242
+ console.log(` Timeout: ${SEAL_API_TIMEOUT}ms`);
243
+ console.log(` TLS Reject Unauthorized: ${SEAL_SSL_CONFIG.rejectUnauthorized}`);
244
+ console.log('');
245
+ console.log('Tracing:');
246
+ console.log(` Service Name: ${SERVICE_NAME}`);
247
+ console.log(` Tempo Endpoint: ${TEMPO_ENDPOINT}`);
248
+ console.log(` Enabled: ${TRACING_ENABLED}`);
249
+ console.log('');
250
+ console.log('Processing:');
251
+ console.log(` Instance ID: ${INSTANCE_ID}`);
252
+ console.log(` Max Concurrent: ${MAX_CONCURRENT_MESSAGES}`);
253
+ console.log(` Verbose Logs: ${VERBOSE_LOGS}`);
254
+ console.log('');
255
+ console.log('='.repeat(60));
256
+ console.log('');
257
+ }
258
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../config/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAE9C,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE1D,gFAAgF;AAChF,sBAAsB;AACtB,gFAAgF;AAEhF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,8BAA8B,CAAC;AAErF;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,6CAA6C;IAC7C,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAElD,wBAAwB;IACxB,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,cAAc;IACvD,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,qBAAqB;IAE5D,SAAS;IACT,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,YAAY;IAEzD,qCAAqC;IACrC,iBAAiB,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,OAAO,CAAC;IAC5E,cAAc,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG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AAC;IAChB,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC3B,OAAO,CAAC,GAAG,CAAC,kBAAkB,WAAW,EAAE,CAAC,CAAC;IAC7C,OAAO,CAAC,GAAG,CAAC,qBAAqB,uBAAuB,EAAE,CAAC,CAAC;IAC5D,OAAO,CAAC,GAAG,CAAC,mBAAmB,YAAY,EAAE,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5B,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC"}
@@ -0,0 +1,149 @@
1
+ /**
2
+ * JSON Encryptor Library
3
+ * Fully parameterized encryption library for JSON data
4
+ * Supports asymmetric encryption using Seal API with customizable configuration
5
+ */
6
+ /**
7
+ * Configuration for JSON encryption
8
+ */
9
+ export interface JsonEncryptorConfig {
10
+ apiBaseUrl: string;
11
+ apiTimeout?: number;
12
+ tlsConfig?: {
13
+ clientCertPath?: string;
14
+ clientKeyPath?: string;
15
+ caPath?: string;
16
+ rejectUnauthorized?: boolean;
17
+ };
18
+ publicKeys: string[];
19
+ requestIdPrefix?: string;
20
+ enableLogging?: boolean;
21
+ }
22
+ /**
23
+ * Encrypted JSON output format
24
+ */
25
+ export interface EncryptedJson {
26
+ requestId?: string;
27
+ data: string;
28
+ worker_name?: string;
29
+ source_topic?: string;
30
+ encryptionMethod: 'seal-api';
31
+ timestamp?: number;
32
+ }
33
+ /**
34
+ * Decrypted JSON output format
35
+ */
36
+ export interface DecryptedJson<T = any> {
37
+ data: T;
38
+ requestId?: string;
39
+ timestamp: number;
40
+ }
41
+ /**
42
+ * JSON Encryptor Class
43
+ * Provides parameterized JSON encryption/decryption functionality
44
+ */
45
+ export declare class JsonEncryptor {
46
+ private config;
47
+ private httpsAgent?;
48
+ constructor(config: JsonEncryptorConfig);
49
+ /**
50
+ * Validate configuration
51
+ */
52
+ private validateConfig;
53
+ /**
54
+ * Create HTTPS agent with TLS configuration
55
+ */
56
+ private createHttpsAgent;
57
+ /**
58
+ * Generate unique request ID
59
+ */
60
+ private generateRequestId;
61
+ /**
62
+ * Log message if logging is enabled
63
+ */
64
+ private log;
65
+ /**
66
+ * Convert JSON object to base64 string
67
+ */
68
+ private jsonToBase64;
69
+ /**
70
+ * Convert base64 string to JSON object
71
+ */
72
+ private base64ToJson;
73
+ /**
74
+ * Make HTTPS request to Seal API
75
+ */
76
+ private makeHttpsRequest;
77
+ /**
78
+ * Make HTTPS request using Bun's fetch API with TLS support
79
+ */
80
+ private makeFetchRequest;
81
+ /**
82
+ * Encrypt JSON data
83
+ *
84
+ * @param data - JSON data to encrypt (any serializable object)
85
+ * @param options - Optional encryption options
86
+ * @returns Promise<EncryptedJson> - Encrypted data with metadata
87
+ *
88
+ * @example
89
+ * const encrypted = await encryptor.encrypt({ message: 'Hello', value: 123 });
90
+ * console.log(encrypted.ciphertext);
91
+ */
92
+ encrypt<T = any>(data: T, options?: {
93
+ requestId?: string;
94
+ publicKeys?: string[];
95
+ }): Promise<EncryptedJson>;
96
+ /**
97
+ * Decrypt encrypted JSON data
98
+ *
99
+ * @param encryptedData - Encrypted data from encrypt() method or ciphertext string
100
+ * @returns Promise<DecryptedJson<T>> - Decrypted data with metadata
101
+ *
102
+ * @example
103
+ * const decrypted = await encryptor.decrypt(encrypted);
104
+ * console.log(decrypted.data);
105
+ */
106
+ decrypt<T = any>(encryptedData: EncryptedJson | string): Promise<DecryptedJson<T>>;
107
+ /**
108
+ * Encrypt multiple JSON objects in batch
109
+ *
110
+ * @param dataArray - Array of JSON objects to encrypt
111
+ * @param options - Optional encryption options
112
+ * @returns Promise<EncryptedJson[]> - Array of encrypted data
113
+ */
114
+ encryptBatch<T = any>(dataArray: T[], options?: {
115
+ requestIdPrefix?: string;
116
+ publicKeys?: string[];
117
+ }): Promise<EncryptedJson[]>;
118
+ /**
119
+ * Update configuration
120
+ */
121
+ updateConfig(config: Partial<JsonEncryptorConfig>): void;
122
+ /**
123
+ * Get current configuration (read-only)
124
+ */
125
+ getConfig(): Readonly<Required<JsonEncryptorConfig>>;
126
+ }
127
+ /**
128
+ * Create a JsonEncryptor instance with configuration
129
+ *
130
+ * @param config - Configuration object
131
+ * @returns JsonEncryptor instance
132
+ *
133
+ * @example
134
+ * const encryptor = createJsonEncryptor({
135
+ * apiBaseUrl: 'https://192.168.112.153:2798',
136
+ * publicKeys: [publicKey1, publicKey2],
137
+ * tlsConfig: {
138
+ * clientCertPath: './client.crt',
139
+ * clientKeyPath: './client.key',
140
+ * rejectUnauthorized: false,
141
+ * },
142
+ * enableLogging: true,
143
+ * });
144
+ *
145
+ * const encrypted = await encryptor.encrypt({ message: 'Hello World' });
146
+ * const decrypted = await encryptor.decrypt(encrypted);
147
+ */
148
+ export declare function createJsonEncryptor(config: JsonEncryptorConfig): JsonEncryptor;
149
+ //# sourceMappingURL=json-encryptor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-encryptor.d.ts","sourceRoot":"","sources":["../../../lib/crypto/json-encryptor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAElC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IAGpB,SAAS,CAAC,EAAE;QACV,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,kBAAkB,CAAC,EAAE,OAAO,CAAC;KAC9B,CAAC;IAGF,UAAU,EAAE,MAAM,EAAE,CAAC;IAGrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAA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