node-consul-service 1.0.43 → 1.0.45

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.
@@ -1,3 +1,9 @@
1
1
  import Consul from "consul";
2
- declare const client: Consul;
3
- export default client;
2
+ interface ConsulConfig {
3
+ host: string;
4
+ port: number;
5
+ secure?: boolean;
6
+ }
7
+ export declare function initClient(config: ConsulConfig): void;
8
+ export declare function getClient(): Consul;
9
+ export {};
package/dist/index.cjs.js CHANGED
@@ -1,422 +1,43 @@
1
1
  'use strict';
2
2
 
3
- var require$$0$1 = require('fs');
4
- var require$$1 = require('path');
5
- var require$$2 = require('os');
6
- var require$$3 = require('crypto');
7
3
  var Consul = require('consul');
8
- var require$$1$1 = require('util');
4
+ var require$$1 = require('util');
9
5
  var stream = require('stream');
10
- var require$$3$1 = require('http');
11
- var require$$4$1 = require('https');
12
- var require$$0$2 = require('url');
13
- var require$$4$2 = require('assert');
6
+ var require$$1$1 = require('path');
7
+ var require$$3 = require('http');
8
+ var require$$4 = require('https');
9
+ var require$$0$1 = require('url');
10
+ var require$$6 = require('fs');
11
+ var crypto = require('crypto');
12
+ var require$$4$1 = require('assert');
14
13
  var zlib = require('zlib');
15
14
  var events = require('events');
16
15
 
17
- function getDefaultExportFromCjs (x) {
18
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
19
- }
20
-
21
- var main = {exports: {}};
22
-
23
- var version = "16.5.0";
24
- var require$$4 = {
25
- version: version};
26
-
27
- var hasRequiredMain;
28
-
29
- function requireMain () {
30
- if (hasRequiredMain) return main.exports;
31
- hasRequiredMain = 1;
32
- const fs = require$$0$1;
33
- const path = require$$1;
34
- const os = require$$2;
35
- const crypto = require$$3;
36
- const packageJson = require$$4;
37
-
38
- const version = packageJson.version;
39
-
40
- const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
41
-
42
- // Parse src into an Object
43
- function parse (src) {
44
- const obj = {};
45
-
46
- // Convert buffer to string
47
- let lines = src.toString();
48
-
49
- // Convert line breaks to same format
50
- lines = lines.replace(/\r\n?/mg, '\n');
51
-
52
- let match;
53
- while ((match = LINE.exec(lines)) != null) {
54
- const key = match[1];
55
-
56
- // Default undefined or null to empty string
57
- let value = (match[2] || '');
58
-
59
- // Remove whitespace
60
- value = value.trim();
61
-
62
- // Check if double quoted
63
- const maybeQuote = value[0];
64
-
65
- // Remove surrounding quotes
66
- value = value.replace(/^(['"`])([\s\S]*)\1$/mg, '$2');
67
-
68
- // Expand newlines if double quoted
69
- if (maybeQuote === '"') {
70
- value = value.replace(/\\n/g, '\n');
71
- value = value.replace(/\\r/g, '\r');
72
- }
73
-
74
- // Add to object
75
- obj[key] = value;
76
- }
77
-
78
- return obj
79
- }
80
-
81
- function _parseVault (options) {
82
- const vaultPath = _vaultPath(options);
83
-
84
- // Parse .env.vault
85
- const result = DotenvModule.configDotenv({ path: vaultPath });
86
- if (!result.parsed) {
87
- const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
88
- err.code = 'MISSING_DATA';
89
- throw err
90
- }
91
-
92
- // handle scenario for comma separated keys - for use with key rotation
93
- // example: DOTENV_KEY="dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod"
94
- const keys = _dotenvKey(options).split(',');
95
- const length = keys.length;
96
-
97
- let decrypted;
98
- for (let i = 0; i < length; i++) {
99
- try {
100
- // Get full key
101
- const key = keys[i].trim();
102
-
103
- // Get instructions for decrypt
104
- const attrs = _instructions(result, key);
105
-
106
- // Decrypt
107
- decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
108
-
109
- break
110
- } catch (error) {
111
- // last key
112
- if (i + 1 >= length) {
113
- throw error
114
- }
115
- // try next key
116
- }
117
- }
118
-
119
- // Parse decrypted .env string
120
- return DotenvModule.parse(decrypted)
121
- }
122
-
123
- function _warn (message) {
124
- console.log(`[dotenv@${version}][WARN] ${message}`);
125
- }
126
-
127
- function _debug (message) {
128
- console.log(`[dotenv@${version}][DEBUG] ${message}`);
129
- }
130
-
131
- function _dotenvKey (options) {
132
- // prioritize developer directly setting options.DOTENV_KEY
133
- if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
134
- return options.DOTENV_KEY
135
- }
136
-
137
- // secondary infra already contains a DOTENV_KEY environment variable
138
- if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
139
- return process.env.DOTENV_KEY
140
- }
141
-
142
- // fallback to empty string
143
- return ''
144
- }
145
-
146
- function _instructions (result, dotenvKey) {
147
- // Parse DOTENV_KEY. Format is a URI
148
- let uri;
149
- try {
150
- uri = new URL(dotenvKey);
151
- } catch (error) {
152
- if (error.code === 'ERR_INVALID_URL') {
153
- const err = new Error('INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development');
154
- err.code = 'INVALID_DOTENV_KEY';
155
- throw err
156
- }
157
-
158
- throw error
159
- }
160
-
161
- // Get decrypt key
162
- const key = uri.password;
163
- if (!key) {
164
- const err = new Error('INVALID_DOTENV_KEY: Missing key part');
165
- err.code = 'INVALID_DOTENV_KEY';
166
- throw err
167
- }
168
-
169
- // Get environment
170
- const environment = uri.searchParams.get('environment');
171
- if (!environment) {
172
- const err = new Error('INVALID_DOTENV_KEY: Missing environment part');
173
- err.code = 'INVALID_DOTENV_KEY';
174
- throw err
175
- }
176
-
177
- // Get ciphertext payload
178
- const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
179
- const ciphertext = result.parsed[environmentKey]; // DOTENV_VAULT_PRODUCTION
180
- if (!ciphertext) {
181
- const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
182
- err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT';
183
- throw err
184
- }
185
-
186
- return { ciphertext, key }
187
- }
188
-
189
- function _vaultPath (options) {
190
- let possibleVaultPath = null;
191
-
192
- if (options && options.path && options.path.length > 0) {
193
- if (Array.isArray(options.path)) {
194
- for (const filepath of options.path) {
195
- if (fs.existsSync(filepath)) {
196
- possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`;
197
- }
198
- }
199
- } else {
200
- possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`;
201
- }
202
- } else {
203
- possibleVaultPath = path.resolve(process.cwd(), '.env.vault');
204
- }
205
-
206
- if (fs.existsSync(possibleVaultPath)) {
207
- return possibleVaultPath
208
- }
209
-
210
- return null
211
- }
212
-
213
- function _resolveHome (envPath) {
214
- return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath
215
- }
216
-
217
- function _configVault (options) {
218
- const debug = Boolean(options && options.debug);
219
- if (debug) {
220
- _debug('Loading env from encrypted .env.vault');
221
- }
222
-
223
- const parsed = DotenvModule._parseVault(options);
224
-
225
- let processEnv = process.env;
226
- if (options && options.processEnv != null) {
227
- processEnv = options.processEnv;
228
- }
229
-
230
- DotenvModule.populate(processEnv, parsed, options);
231
-
232
- return { parsed }
233
- }
234
-
235
- function configDotenv (options) {
236
- const dotenvPath = path.resolve(process.cwd(), '.env');
237
- let encoding = 'utf8';
238
- const debug = Boolean(options && options.debug);
239
-
240
- if (options && options.encoding) {
241
- encoding = options.encoding;
242
- } else {
243
- if (debug) {
244
- _debug('No encoding is specified. UTF-8 is used by default');
245
- }
246
- }
247
-
248
- let optionPaths = [dotenvPath]; // default, look for .env
249
- if (options && options.path) {
250
- if (!Array.isArray(options.path)) {
251
- optionPaths = [_resolveHome(options.path)];
252
- } else {
253
- optionPaths = []; // reset default
254
- for (const filepath of options.path) {
255
- optionPaths.push(_resolveHome(filepath));
256
- }
257
- }
258
- }
259
-
260
- // Build the parsed data in a temporary object (because we need to return it). Once we have the final
261
- // parsed data, we will combine it with process.env (or options.processEnv if provided).
262
- let lastError;
263
- const parsedAll = {};
264
- for (const path of optionPaths) {
265
- try {
266
- // Specifying an encoding returns a string instead of a buffer
267
- const parsed = DotenvModule.parse(fs.readFileSync(path, { encoding }));
268
-
269
- DotenvModule.populate(parsedAll, parsed, options);
270
- } catch (e) {
271
- if (debug) {
272
- _debug(`Failed to load ${path} ${e.message}`);
273
- }
274
- lastError = e;
275
- }
276
- }
277
-
278
- let processEnv = process.env;
279
- if (options && options.processEnv != null) {
280
- processEnv = options.processEnv;
281
- }
282
-
283
- DotenvModule.populate(processEnv, parsedAll, options);
284
-
285
- if (lastError) {
286
- return { parsed: parsedAll, error: lastError }
287
- } else {
288
- return { parsed: parsedAll }
289
- }
290
- }
291
-
292
- // Populates process.env from .env file
293
- function config (options) {
294
- // fallback to original dotenv if DOTENV_KEY is not set
295
- if (_dotenvKey(options).length === 0) {
296
- return DotenvModule.configDotenv(options)
297
- }
298
-
299
- const vaultPath = _vaultPath(options);
300
-
301
- // dotenvKey exists but .env.vault file does not exist
302
- if (!vaultPath) {
303
- _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
304
-
305
- return DotenvModule.configDotenv(options)
306
- }
307
-
308
- return DotenvModule._configVault(options)
309
- }
310
-
311
- function decrypt (encrypted, keyStr) {
312
- const key = Buffer.from(keyStr.slice(-64), 'hex');
313
- let ciphertext = Buffer.from(encrypted, 'base64');
314
-
315
- const nonce = ciphertext.subarray(0, 12);
316
- const authTag = ciphertext.subarray(-16);
317
- ciphertext = ciphertext.subarray(12, -16);
318
-
319
- try {
320
- const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce);
321
- aesgcm.setAuthTag(authTag);
322
- return `${aesgcm.update(ciphertext)}${aesgcm.final()}`
323
- } catch (error) {
324
- const isRange = error instanceof RangeError;
325
- const invalidKeyLength = error.message === 'Invalid key length';
326
- const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data';
327
-
328
- if (isRange || invalidKeyLength) {
329
- const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)');
330
- err.code = 'INVALID_DOTENV_KEY';
331
- throw err
332
- } else if (decryptionFailed) {
333
- const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY');
334
- err.code = 'DECRYPTION_FAILED';
335
- throw err
336
- } else {
337
- throw error
338
- }
339
- }
340
- }
341
-
342
- // Populate process.env with parsed values
343
- function populate (processEnv, parsed, options = {}) {
344
- const debug = Boolean(options && options.debug);
345
- const override = Boolean(options && options.override);
346
-
347
- if (typeof parsed !== 'object') {
348
- const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate');
349
- err.code = 'OBJECT_REQUIRED';
350
- throw err
351
- }
352
-
353
- // Set process.env
354
- for (const key of Object.keys(parsed)) {
355
- if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
356
- if (override === true) {
357
- processEnv[key] = parsed[key];
358
- }
359
-
360
- if (debug) {
361
- if (override === true) {
362
- _debug(`"${key}" is already defined and WAS overwritten`);
363
- } else {
364
- _debug(`"${key}" is already defined and was NOT overwritten`);
365
- }
366
- }
367
- } else {
368
- processEnv[key] = parsed[key];
369
- }
370
- }
371
- }
372
-
373
- const DotenvModule = {
374
- configDotenv,
375
- _configVault,
376
- _parseVault,
377
- config,
378
- decrypt,
379
- parse,
380
- populate
381
- };
382
-
383
- main.exports.configDotenv = DotenvModule.configDotenv;
384
- main.exports._configVault = DotenvModule._configVault;
385
- main.exports._parseVault = DotenvModule._parseVault;
386
- main.exports.config = DotenvModule.config;
387
- main.exports.decrypt = DotenvModule.decrypt;
388
- main.exports.parse = DotenvModule.parse;
389
- main.exports.populate = DotenvModule.populate;
390
-
391
- main.exports = DotenvModule;
392
- return main.exports;
393
- }
394
-
395
- var mainExports = requireMain();
396
- var dotenv = /*@__PURE__*/getDefaultExportFromCjs(mainExports);
397
-
398
- dotenv.config();
399
- const { CONSUL_HOST, CONSUL_PORT, CONSUL_SECURE } = process.env;
400
- if (!CONSUL_HOST) {
401
- throw new Error("Missing environment variable: CONSUL_HOST");
402
- }
403
- if (!CONSUL_PORT) {
404
- throw new Error("Missing environment variable: CONSUL_PORT");
16
+ // src/lib/client.ts
17
+ let consulClient = null;
18
+ function initClient(config) {
19
+ var _a;
20
+ consulClient = new Consul({
21
+ host: config.host,
22
+ port: config.port,
23
+ secure: (_a = config.secure) !== null && _a !== void 0 ? _a : true,
24
+ });
25
+ // optional test connection
26
+ consulClient.agent.self((err) => {
27
+ if (err) {
28
+ console.error("❌ Failed to connect to Consul:", err.message);
29
+ }
30
+ else {
31
+ console.log("✅ Connected to Consul successfully");
32
+ }
33
+ });
405
34
  }
406
- const client = new Consul({
407
- host: CONSUL_HOST,
408
- port: Number(CONSUL_PORT),
409
- secure: CONSUL_SECURE === "true",
410
- });
411
- // اختبار الاتصال
412
- client.agent.self((err) => {
413
- if (err) {
414
- console.error("❌ Failed to connect to Consul:", err.message);
415
- }
416
- else {
417
- console.log("✅ Connected to Consul successfully");
35
+ function getClient() {
36
+ if (!consulClient) {
37
+ throw new Error("Consul client not initialized. Call initClient() first.");
418
38
  }
419
- });
39
+ return consulClient;
40
+ }
420
41
 
421
42
  const registeredServices = new Set();
422
43
  async function registerService(options) {
@@ -446,7 +67,7 @@ async function registerService(options) {
446
67
  }
447
68
  serviceDefinition.check = checkDefinition;
448
69
  }
449
- await client.agent.service.register(serviceDefinition);
70
+ await getClient().agent.service.register(serviceDefinition);
450
71
  registeredServices.add(id);
451
72
  console.log(`✅ Service "${id}" registered successfully.`);
452
73
  }
@@ -455,17 +76,17 @@ async function deregisterService(id) {
455
76
  console.log(`⚠️ Service "${id}" is not registered.`);
456
77
  return;
457
78
  }
458
- await client.agent.service.deregister(id);
79
+ await getClient().agent.service.deregister(id);
459
80
  registeredServices.delete(id);
460
81
  console.log(`🛑 Service "${id}" deregistered successfully.`);
461
82
  }
462
83
 
463
84
  async function listServices() {
464
- const services = await client.agent.service.list();
85
+ const services = await getClient().agent.service.list();
465
86
  return Object.values(services);
466
87
  }
467
88
  async function getServiceInstances(serviceName) {
468
- const services = await client.catalog.service.nodes(serviceName);
89
+ const services = await getClient().catalog.service.nodes(serviceName);
469
90
  return services;
470
91
  }
471
92
  async function getRandomServiceInstance(serviceName) {
@@ -1325,6 +946,10 @@ AxiosError$1.from = (error, code, config, request, response, customProps) => {
1325
946
  return axiosError;
1326
947
  };
1327
948
 
949
+ function getDefaultExportFromCjs (x) {
950
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
951
+ }
952
+
1328
953
  var delayed_stream;
1329
954
  var hasRequiredDelayed_stream;
1330
955
 
@@ -1332,7 +957,7 @@ function requireDelayed_stream () {
1332
957
  if (hasRequiredDelayed_stream) return delayed_stream;
1333
958
  hasRequiredDelayed_stream = 1;
1334
959
  var Stream = stream.Stream;
1335
- var util = require$$1$1;
960
+ var util = require$$1;
1336
961
 
1337
962
  delayed_stream = DelayedStream;
1338
963
  function DelayedStream() {
@@ -1447,7 +1072,7 @@ var hasRequiredCombined_stream;
1447
1072
  function requireCombined_stream () {
1448
1073
  if (hasRequiredCombined_stream) return combined_stream;
1449
1074
  hasRequiredCombined_stream = 1;
1450
- var util = require$$1$1;
1075
+ var util = require$$1;
1451
1076
  var Stream = stream.Stream;
1452
1077
  var DelayedStream = requireDelayed_stream();
1453
1078
 
@@ -12404,7 +12029,7 @@ function requireMimeTypes () {
12404
12029
  */
12405
12030
 
12406
12031
  var db = requireMimeDb();
12407
- var extname = require$$1.extname;
12032
+ var extname = require$$1$1.extname;
12408
12033
 
12409
12034
  /**
12410
12035
  * Module variables.
@@ -14144,12 +13769,12 @@ function requireForm_data () {
14144
13769
  if (hasRequiredForm_data) return form_data;
14145
13770
  hasRequiredForm_data = 1;
14146
13771
  var CombinedStream = requireCombined_stream();
14147
- var util = require$$1$1;
14148
- var path = require$$1;
14149
- var http = require$$3$1;
14150
- var https = require$$4$1;
14151
- var parseUrl = require$$0$2.parse;
14152
- var fs = require$$0$1;
13772
+ var util = require$$1;
13773
+ var path = require$$1$1;
13774
+ var http = require$$3;
13775
+ var https = require$$4;
13776
+ var parseUrl = require$$0$1.parse;
13777
+ var fs = require$$6;
14153
13778
  var Stream = stream.Stream;
14154
13779
  var mime = requireMimeTypes();
14155
13780
  var asynckit = requireAsynckit();
@@ -15053,7 +14678,7 @@ var transitionalDefaults = {
15053
14678
  clarifyTimeoutError: false
15054
14679
  };
15055
14680
 
15056
- var URLSearchParams = require$$0$2.URLSearchParams;
14681
+ var URLSearchParams = require$$0$1.URLSearchParams;
15057
14682
 
15058
14683
  const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
15059
14684
 
@@ -15069,7 +14694,7 @@ const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
15069
14694
  let str = '';
15070
14695
  const {length} = alphabet;
15071
14696
  const randomValues = new Uint32Array(size);
15072
- require$$3.randomFillSync(randomValues);
14697
+ crypto.randomFillSync(randomValues);
15073
14698
  for (let i = 0; i < size; i++) {
15074
14699
  str += alphabet[randomValues[i] % length];
15075
14700
  }
@@ -15135,12 +14760,12 @@ const hasStandardBrowserWebWorkerEnv = (() => {
15135
14760
  const origin = hasBrowserEnv && window.location.href || 'http://localhost';
15136
14761
 
15137
14762
  var utils = /*#__PURE__*/Object.freeze({
15138
- __proto__: null,
15139
- hasBrowserEnv: hasBrowserEnv,
15140
- hasStandardBrowserEnv: hasStandardBrowserEnv,
15141
- hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
15142
- navigator: _navigator,
15143
- origin: origin
14763
+ __proto__: null,
14764
+ hasBrowserEnv: hasBrowserEnv,
14765
+ hasStandardBrowserEnv: hasStandardBrowserEnv,
14766
+ hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
14767
+ navigator: _navigator,
14768
+ origin: origin
15144
14769
  });
15145
14770
 
15146
14771
  var platform = {
@@ -15885,7 +15510,7 @@ function requireProxyFromEnv () {
15885
15510
  if (hasRequiredProxyFromEnv) return proxyFromEnv$1;
15886
15511
  hasRequiredProxyFromEnv = 1;
15887
15512
 
15888
- var parseUrl = require$$0$2.parse;
15513
+ var parseUrl = require$$0$1.parse;
15889
15514
 
15890
15515
  var DEFAULT_PORTS = {
15891
15516
  ftp: 21,
@@ -16028,12 +15653,12 @@ var hasRequiredFollowRedirects;
16028
15653
  function requireFollowRedirects () {
16029
15654
  if (hasRequiredFollowRedirects) return followRedirects$1.exports;
16030
15655
  hasRequiredFollowRedirects = 1;
16031
- var url = require$$0$2;
15656
+ var url = require$$0$1;
16032
15657
  var URL = url.URL;
16033
- var http = require$$3$1;
16034
- var https = require$$4$1;
15658
+ var http = require$$3;
15659
+ var https = require$$4;
16035
15660
  var Writable = stream.Writable;
16036
- var assert = require$$4$2;
15661
+ var assert = require$$4$1;
16037
15662
  var debug = requireDebug();
16038
15663
 
16039
15664
  // Preventive platform detection
@@ -16928,7 +16553,7 @@ const readBlob = async function* (blob) {
16928
16553
 
16929
16554
  const BOUNDARY_ALPHABET = platform.ALPHABET.ALPHA_DIGIT + '-_';
16930
16555
 
16931
- const textEncoder = typeof TextEncoder === 'function' ? new TextEncoder() : new require$$1$1.TextEncoder();
16556
+ const textEncoder = typeof TextEncoder === 'function' ? new TextEncoder() : new require$$1.TextEncoder();
16932
16557
 
16933
16558
  const CRLF = '\r\n';
16934
16559
  const CRLF_BYTES = textEncoder.encode(CRLF);
@@ -17485,7 +17110,7 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17485
17110
 
17486
17111
  if (!headers.hasContentLength()) {
17487
17112
  try {
17488
- const knownLength = await require$$1$1.promisify(data.getLength).call(data);
17113
+ const knownLength = await require$$1.promisify(data.getLength).call(data);
17489
17114
  Number.isFinite(knownLength) && knownLength >= 0 && headers.setContentLength(knownLength);
17490
17115
  /*eslint no-empty:0*/
17491
17116
  } catch (e) {
@@ -17613,7 +17238,7 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17613
17238
  if (config.transport) {
17614
17239
  transport = config.transport;
17615
17240
  } else if (config.maxRedirects === 0) {
17616
- transport = isHttpsRequest ? require$$4$1 : require$$3$1;
17241
+ transport = isHttpsRequest ? require$$4 : require$$3;
17617
17242
  } else {
17618
17243
  if (config.maxRedirects) {
17619
17244
  options.maxRedirects = config.maxRedirects;
@@ -19550,9 +19175,11 @@ exports.DataLinkError = DataLinkError;
19550
19175
  exports.callService = callService;
19551
19176
  exports.dataLink = dataLink;
19552
19177
  exports.deregisterService = deregisterService;
19178
+ exports.getClient = getClient;
19553
19179
  exports.getRandomServiceInstance = getRandomServiceInstance;
19554
19180
  exports.getServiceInstances = getServiceInstances;
19555
19181
  exports.getServiceUrl = getServiceUrl;
19182
+ exports.initClient = initClient;
19556
19183
  exports.listServices = listServices;
19557
19184
  exports.registerService = registerService;
19558
19185
  //# sourceMappingURL=index.cjs.js.map
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './consul/client';
1
2
  export * from './consul/registry';
2
3
  export * from './consul/discovery';
3
4
  export * from './consul/httpCaller';
package/dist/index.esm.js CHANGED
@@ -1,420 +1,41 @@
1
- import require$$0$1 from 'fs';
2
- import require$$1 from 'path';
3
- import require$$2 from 'os';
4
- import require$$3 from 'crypto';
5
1
  import Consul from 'consul';
6
- import require$$1$1 from 'util';
2
+ import require$$1 from 'util';
7
3
  import stream, { Readable } from 'stream';
8
- import require$$3$1 from 'http';
9
- import require$$4$1 from 'https';
10
- import require$$0$2 from 'url';
11
- import require$$4$2 from 'assert';
4
+ import require$$1$1 from 'path';
5
+ import require$$3 from 'http';
6
+ import require$$4 from 'https';
7
+ import require$$0$1 from 'url';
8
+ import require$$6 from 'fs';
9
+ import crypto from 'crypto';
10
+ import require$$4$1 from 'assert';
12
11
  import zlib from 'zlib';
13
12
  import { EventEmitter } from 'events';
14
13
 
15
- function getDefaultExportFromCjs (x) {
16
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
17
- }
18
-
19
- var main = {exports: {}};
20
-
21
- var version = "16.5.0";
22
- var require$$4 = {
23
- version: version};
24
-
25
- var hasRequiredMain;
26
-
27
- function requireMain () {
28
- if (hasRequiredMain) return main.exports;
29
- hasRequiredMain = 1;
30
- const fs = require$$0$1;
31
- const path = require$$1;
32
- const os = require$$2;
33
- const crypto = require$$3;
34
- const packageJson = require$$4;
35
-
36
- const version = packageJson.version;
37
-
38
- const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
39
-
40
- // Parse src into an Object
41
- function parse (src) {
42
- const obj = {};
43
-
44
- // Convert buffer to string
45
- let lines = src.toString();
46
-
47
- // Convert line breaks to same format
48
- lines = lines.replace(/\r\n?/mg, '\n');
49
-
50
- let match;
51
- while ((match = LINE.exec(lines)) != null) {
52
- const key = match[1];
53
-
54
- // Default undefined or null to empty string
55
- let value = (match[2] || '');
56
-
57
- // Remove whitespace
58
- value = value.trim();
59
-
60
- // Check if double quoted
61
- const maybeQuote = value[0];
62
-
63
- // Remove surrounding quotes
64
- value = value.replace(/^(['"`])([\s\S]*)\1$/mg, '$2');
65
-
66
- // Expand newlines if double quoted
67
- if (maybeQuote === '"') {
68
- value = value.replace(/\\n/g, '\n');
69
- value = value.replace(/\\r/g, '\r');
70
- }
71
-
72
- // Add to object
73
- obj[key] = value;
74
- }
75
-
76
- return obj
77
- }
78
-
79
- function _parseVault (options) {
80
- const vaultPath = _vaultPath(options);
81
-
82
- // Parse .env.vault
83
- const result = DotenvModule.configDotenv({ path: vaultPath });
84
- if (!result.parsed) {
85
- const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
86
- err.code = 'MISSING_DATA';
87
- throw err
88
- }
89
-
90
- // handle scenario for comma separated keys - for use with key rotation
91
- // example: DOTENV_KEY="dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod"
92
- const keys = _dotenvKey(options).split(',');
93
- const length = keys.length;
94
-
95
- let decrypted;
96
- for (let i = 0; i < length; i++) {
97
- try {
98
- // Get full key
99
- const key = keys[i].trim();
100
-
101
- // Get instructions for decrypt
102
- const attrs = _instructions(result, key);
103
-
104
- // Decrypt
105
- decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
106
-
107
- break
108
- } catch (error) {
109
- // last key
110
- if (i + 1 >= length) {
111
- throw error
112
- }
113
- // try next key
114
- }
115
- }
116
-
117
- // Parse decrypted .env string
118
- return DotenvModule.parse(decrypted)
119
- }
120
-
121
- function _warn (message) {
122
- console.log(`[dotenv@${version}][WARN] ${message}`);
123
- }
124
-
125
- function _debug (message) {
126
- console.log(`[dotenv@${version}][DEBUG] ${message}`);
127
- }
128
-
129
- function _dotenvKey (options) {
130
- // prioritize developer directly setting options.DOTENV_KEY
131
- if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
132
- return options.DOTENV_KEY
133
- }
134
-
135
- // secondary infra already contains a DOTENV_KEY environment variable
136
- if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
137
- return process.env.DOTENV_KEY
138
- }
139
-
140
- // fallback to empty string
141
- return ''
142
- }
143
-
144
- function _instructions (result, dotenvKey) {
145
- // Parse DOTENV_KEY. Format is a URI
146
- let uri;
147
- try {
148
- uri = new URL(dotenvKey);
149
- } catch (error) {
150
- if (error.code === 'ERR_INVALID_URL') {
151
- const err = new Error('INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development');
152
- err.code = 'INVALID_DOTENV_KEY';
153
- throw err
154
- }
155
-
156
- throw error
157
- }
158
-
159
- // Get decrypt key
160
- const key = uri.password;
161
- if (!key) {
162
- const err = new Error('INVALID_DOTENV_KEY: Missing key part');
163
- err.code = 'INVALID_DOTENV_KEY';
164
- throw err
165
- }
166
-
167
- // Get environment
168
- const environment = uri.searchParams.get('environment');
169
- if (!environment) {
170
- const err = new Error('INVALID_DOTENV_KEY: Missing environment part');
171
- err.code = 'INVALID_DOTENV_KEY';
172
- throw err
173
- }
174
-
175
- // Get ciphertext payload
176
- const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
177
- const ciphertext = result.parsed[environmentKey]; // DOTENV_VAULT_PRODUCTION
178
- if (!ciphertext) {
179
- const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
180
- err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT';
181
- throw err
182
- }
183
-
184
- return { ciphertext, key }
185
- }
186
-
187
- function _vaultPath (options) {
188
- let possibleVaultPath = null;
189
-
190
- if (options && options.path && options.path.length > 0) {
191
- if (Array.isArray(options.path)) {
192
- for (const filepath of options.path) {
193
- if (fs.existsSync(filepath)) {
194
- possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`;
195
- }
196
- }
197
- } else {
198
- possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`;
199
- }
200
- } else {
201
- possibleVaultPath = path.resolve(process.cwd(), '.env.vault');
202
- }
203
-
204
- if (fs.existsSync(possibleVaultPath)) {
205
- return possibleVaultPath
206
- }
207
-
208
- return null
209
- }
210
-
211
- function _resolveHome (envPath) {
212
- return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath
213
- }
214
-
215
- function _configVault (options) {
216
- const debug = Boolean(options && options.debug);
217
- if (debug) {
218
- _debug('Loading env from encrypted .env.vault');
219
- }
220
-
221
- const parsed = DotenvModule._parseVault(options);
222
-
223
- let processEnv = process.env;
224
- if (options && options.processEnv != null) {
225
- processEnv = options.processEnv;
226
- }
227
-
228
- DotenvModule.populate(processEnv, parsed, options);
229
-
230
- return { parsed }
231
- }
232
-
233
- function configDotenv (options) {
234
- const dotenvPath = path.resolve(process.cwd(), '.env');
235
- let encoding = 'utf8';
236
- const debug = Boolean(options && options.debug);
237
-
238
- if (options && options.encoding) {
239
- encoding = options.encoding;
240
- } else {
241
- if (debug) {
242
- _debug('No encoding is specified. UTF-8 is used by default');
243
- }
244
- }
245
-
246
- let optionPaths = [dotenvPath]; // default, look for .env
247
- if (options && options.path) {
248
- if (!Array.isArray(options.path)) {
249
- optionPaths = [_resolveHome(options.path)];
250
- } else {
251
- optionPaths = []; // reset default
252
- for (const filepath of options.path) {
253
- optionPaths.push(_resolveHome(filepath));
254
- }
255
- }
256
- }
257
-
258
- // Build the parsed data in a temporary object (because we need to return it). Once we have the final
259
- // parsed data, we will combine it with process.env (or options.processEnv if provided).
260
- let lastError;
261
- const parsedAll = {};
262
- for (const path of optionPaths) {
263
- try {
264
- // Specifying an encoding returns a string instead of a buffer
265
- const parsed = DotenvModule.parse(fs.readFileSync(path, { encoding }));
266
-
267
- DotenvModule.populate(parsedAll, parsed, options);
268
- } catch (e) {
269
- if (debug) {
270
- _debug(`Failed to load ${path} ${e.message}`);
271
- }
272
- lastError = e;
273
- }
274
- }
275
-
276
- let processEnv = process.env;
277
- if (options && options.processEnv != null) {
278
- processEnv = options.processEnv;
279
- }
280
-
281
- DotenvModule.populate(processEnv, parsedAll, options);
282
-
283
- if (lastError) {
284
- return { parsed: parsedAll, error: lastError }
285
- } else {
286
- return { parsed: parsedAll }
287
- }
288
- }
289
-
290
- // Populates process.env from .env file
291
- function config (options) {
292
- // fallback to original dotenv if DOTENV_KEY is not set
293
- if (_dotenvKey(options).length === 0) {
294
- return DotenvModule.configDotenv(options)
295
- }
296
-
297
- const vaultPath = _vaultPath(options);
298
-
299
- // dotenvKey exists but .env.vault file does not exist
300
- if (!vaultPath) {
301
- _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
302
-
303
- return DotenvModule.configDotenv(options)
304
- }
305
-
306
- return DotenvModule._configVault(options)
307
- }
308
-
309
- function decrypt (encrypted, keyStr) {
310
- const key = Buffer.from(keyStr.slice(-64), 'hex');
311
- let ciphertext = Buffer.from(encrypted, 'base64');
312
-
313
- const nonce = ciphertext.subarray(0, 12);
314
- const authTag = ciphertext.subarray(-16);
315
- ciphertext = ciphertext.subarray(12, -16);
316
-
317
- try {
318
- const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce);
319
- aesgcm.setAuthTag(authTag);
320
- return `${aesgcm.update(ciphertext)}${aesgcm.final()}`
321
- } catch (error) {
322
- const isRange = error instanceof RangeError;
323
- const invalidKeyLength = error.message === 'Invalid key length';
324
- const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data';
325
-
326
- if (isRange || invalidKeyLength) {
327
- const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)');
328
- err.code = 'INVALID_DOTENV_KEY';
329
- throw err
330
- } else if (decryptionFailed) {
331
- const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY');
332
- err.code = 'DECRYPTION_FAILED';
333
- throw err
334
- } else {
335
- throw error
336
- }
337
- }
338
- }
339
-
340
- // Populate process.env with parsed values
341
- function populate (processEnv, parsed, options = {}) {
342
- const debug = Boolean(options && options.debug);
343
- const override = Boolean(options && options.override);
344
-
345
- if (typeof parsed !== 'object') {
346
- const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate');
347
- err.code = 'OBJECT_REQUIRED';
348
- throw err
349
- }
350
-
351
- // Set process.env
352
- for (const key of Object.keys(parsed)) {
353
- if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
354
- if (override === true) {
355
- processEnv[key] = parsed[key];
356
- }
357
-
358
- if (debug) {
359
- if (override === true) {
360
- _debug(`"${key}" is already defined and WAS overwritten`);
361
- } else {
362
- _debug(`"${key}" is already defined and was NOT overwritten`);
363
- }
364
- }
365
- } else {
366
- processEnv[key] = parsed[key];
367
- }
368
- }
369
- }
370
-
371
- const DotenvModule = {
372
- configDotenv,
373
- _configVault,
374
- _parseVault,
375
- config,
376
- decrypt,
377
- parse,
378
- populate
379
- };
380
-
381
- main.exports.configDotenv = DotenvModule.configDotenv;
382
- main.exports._configVault = DotenvModule._configVault;
383
- main.exports._parseVault = DotenvModule._parseVault;
384
- main.exports.config = DotenvModule.config;
385
- main.exports.decrypt = DotenvModule.decrypt;
386
- main.exports.parse = DotenvModule.parse;
387
- main.exports.populate = DotenvModule.populate;
388
-
389
- main.exports = DotenvModule;
390
- return main.exports;
391
- }
392
-
393
- var mainExports = requireMain();
394
- var dotenv = /*@__PURE__*/getDefaultExportFromCjs(mainExports);
395
-
396
- dotenv.config();
397
- const { CONSUL_HOST, CONSUL_PORT, CONSUL_SECURE } = process.env;
398
- if (!CONSUL_HOST) {
399
- throw new Error("Missing environment variable: CONSUL_HOST");
400
- }
401
- if (!CONSUL_PORT) {
402
- throw new Error("Missing environment variable: CONSUL_PORT");
14
+ // src/lib/client.ts
15
+ let consulClient = null;
16
+ function initClient(config) {
17
+ var _a;
18
+ consulClient = new Consul({
19
+ host: config.host,
20
+ port: config.port,
21
+ secure: (_a = config.secure) !== null && _a !== void 0 ? _a : true,
22
+ });
23
+ // optional test connection
24
+ consulClient.agent.self((err) => {
25
+ if (err) {
26
+ console.error("❌ Failed to connect to Consul:", err.message);
27
+ }
28
+ else {
29
+ console.log("✅ Connected to Consul successfully");
30
+ }
31
+ });
403
32
  }
404
- const client = new Consul({
405
- host: CONSUL_HOST,
406
- port: Number(CONSUL_PORT),
407
- secure: CONSUL_SECURE === "true",
408
- });
409
- // اختبار الاتصال
410
- client.agent.self((err) => {
411
- if (err) {
412
- console.error("❌ Failed to connect to Consul:", err.message);
413
- }
414
- else {
415
- console.log("✅ Connected to Consul successfully");
33
+ function getClient() {
34
+ if (!consulClient) {
35
+ throw new Error("Consul client not initialized. Call initClient() first.");
416
36
  }
417
- });
37
+ return consulClient;
38
+ }
418
39
 
419
40
  const registeredServices = new Set();
420
41
  async function registerService(options) {
@@ -444,7 +65,7 @@ async function registerService(options) {
444
65
  }
445
66
  serviceDefinition.check = checkDefinition;
446
67
  }
447
- await client.agent.service.register(serviceDefinition);
68
+ await getClient().agent.service.register(serviceDefinition);
448
69
  registeredServices.add(id);
449
70
  console.log(`✅ Service "${id}" registered successfully.`);
450
71
  }
@@ -453,17 +74,17 @@ async function deregisterService(id) {
453
74
  console.log(`⚠️ Service "${id}" is not registered.`);
454
75
  return;
455
76
  }
456
- await client.agent.service.deregister(id);
77
+ await getClient().agent.service.deregister(id);
457
78
  registeredServices.delete(id);
458
79
  console.log(`🛑 Service "${id}" deregistered successfully.`);
459
80
  }
460
81
 
461
82
  async function listServices() {
462
- const services = await client.agent.service.list();
83
+ const services = await getClient().agent.service.list();
463
84
  return Object.values(services);
464
85
  }
465
86
  async function getServiceInstances(serviceName) {
466
- const services = await client.catalog.service.nodes(serviceName);
87
+ const services = await getClient().catalog.service.nodes(serviceName);
467
88
  return services;
468
89
  }
469
90
  async function getRandomServiceInstance(serviceName) {
@@ -1323,6 +944,10 @@ AxiosError$1.from = (error, code, config, request, response, customProps) => {
1323
944
  return axiosError;
1324
945
  };
1325
946
 
947
+ function getDefaultExportFromCjs (x) {
948
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
949
+ }
950
+
1326
951
  var delayed_stream;
1327
952
  var hasRequiredDelayed_stream;
1328
953
 
@@ -1330,7 +955,7 @@ function requireDelayed_stream () {
1330
955
  if (hasRequiredDelayed_stream) return delayed_stream;
1331
956
  hasRequiredDelayed_stream = 1;
1332
957
  var Stream = stream.Stream;
1333
- var util = require$$1$1;
958
+ var util = require$$1;
1334
959
 
1335
960
  delayed_stream = DelayedStream;
1336
961
  function DelayedStream() {
@@ -1445,7 +1070,7 @@ var hasRequiredCombined_stream;
1445
1070
  function requireCombined_stream () {
1446
1071
  if (hasRequiredCombined_stream) return combined_stream;
1447
1072
  hasRequiredCombined_stream = 1;
1448
- var util = require$$1$1;
1073
+ var util = require$$1;
1449
1074
  var Stream = stream.Stream;
1450
1075
  var DelayedStream = requireDelayed_stream();
1451
1076
 
@@ -12402,7 +12027,7 @@ function requireMimeTypes () {
12402
12027
  */
12403
12028
 
12404
12029
  var db = requireMimeDb();
12405
- var extname = require$$1.extname;
12030
+ var extname = require$$1$1.extname;
12406
12031
 
12407
12032
  /**
12408
12033
  * Module variables.
@@ -14142,12 +13767,12 @@ function requireForm_data () {
14142
13767
  if (hasRequiredForm_data) return form_data;
14143
13768
  hasRequiredForm_data = 1;
14144
13769
  var CombinedStream = requireCombined_stream();
14145
- var util = require$$1$1;
14146
- var path = require$$1;
14147
- var http = require$$3$1;
14148
- var https = require$$4$1;
14149
- var parseUrl = require$$0$2.parse;
14150
- var fs = require$$0$1;
13770
+ var util = require$$1;
13771
+ var path = require$$1$1;
13772
+ var http = require$$3;
13773
+ var https = require$$4;
13774
+ var parseUrl = require$$0$1.parse;
13775
+ var fs = require$$6;
14151
13776
  var Stream = stream.Stream;
14152
13777
  var mime = requireMimeTypes();
14153
13778
  var asynckit = requireAsynckit();
@@ -15051,7 +14676,7 @@ var transitionalDefaults = {
15051
14676
  clarifyTimeoutError: false
15052
14677
  };
15053
14678
 
15054
- var URLSearchParams = require$$0$2.URLSearchParams;
14679
+ var URLSearchParams = require$$0$1.URLSearchParams;
15055
14680
 
15056
14681
  const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
15057
14682
 
@@ -15067,7 +14692,7 @@ const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
15067
14692
  let str = '';
15068
14693
  const {length} = alphabet;
15069
14694
  const randomValues = new Uint32Array(size);
15070
- require$$3.randomFillSync(randomValues);
14695
+ crypto.randomFillSync(randomValues);
15071
14696
  for (let i = 0; i < size; i++) {
15072
14697
  str += alphabet[randomValues[i] % length];
15073
14698
  }
@@ -15133,12 +14758,12 @@ const hasStandardBrowserWebWorkerEnv = (() => {
15133
14758
  const origin = hasBrowserEnv && window.location.href || 'http://localhost';
15134
14759
 
15135
14760
  var utils = /*#__PURE__*/Object.freeze({
15136
- __proto__: null,
15137
- hasBrowserEnv: hasBrowserEnv,
15138
- hasStandardBrowserEnv: hasStandardBrowserEnv,
15139
- hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
15140
- navigator: _navigator,
15141
- origin: origin
14761
+ __proto__: null,
14762
+ hasBrowserEnv: hasBrowserEnv,
14763
+ hasStandardBrowserEnv: hasStandardBrowserEnv,
14764
+ hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
14765
+ navigator: _navigator,
14766
+ origin: origin
15142
14767
  });
15143
14768
 
15144
14769
  var platform = {
@@ -15883,7 +15508,7 @@ function requireProxyFromEnv () {
15883
15508
  if (hasRequiredProxyFromEnv) return proxyFromEnv$1;
15884
15509
  hasRequiredProxyFromEnv = 1;
15885
15510
 
15886
- var parseUrl = require$$0$2.parse;
15511
+ var parseUrl = require$$0$1.parse;
15887
15512
 
15888
15513
  var DEFAULT_PORTS = {
15889
15514
  ftp: 21,
@@ -16026,12 +15651,12 @@ var hasRequiredFollowRedirects;
16026
15651
  function requireFollowRedirects () {
16027
15652
  if (hasRequiredFollowRedirects) return followRedirects$1.exports;
16028
15653
  hasRequiredFollowRedirects = 1;
16029
- var url = require$$0$2;
15654
+ var url = require$$0$1;
16030
15655
  var URL = url.URL;
16031
- var http = require$$3$1;
16032
- var https = require$$4$1;
15656
+ var http = require$$3;
15657
+ var https = require$$4;
16033
15658
  var Writable = stream.Writable;
16034
- var assert = require$$4$2;
15659
+ var assert = require$$4$1;
16035
15660
  var debug = requireDebug();
16036
15661
 
16037
15662
  // Preventive platform detection
@@ -16926,7 +16551,7 @@ const readBlob = async function* (blob) {
16926
16551
 
16927
16552
  const BOUNDARY_ALPHABET = platform.ALPHABET.ALPHA_DIGIT + '-_';
16928
16553
 
16929
- const textEncoder = typeof TextEncoder === 'function' ? new TextEncoder() : new require$$1$1.TextEncoder();
16554
+ const textEncoder = typeof TextEncoder === 'function' ? new TextEncoder() : new require$$1.TextEncoder();
16930
16555
 
16931
16556
  const CRLF = '\r\n';
16932
16557
  const CRLF_BYTES = textEncoder.encode(CRLF);
@@ -17483,7 +17108,7 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17483
17108
 
17484
17109
  if (!headers.hasContentLength()) {
17485
17110
  try {
17486
- const knownLength = await require$$1$1.promisify(data.getLength).call(data);
17111
+ const knownLength = await require$$1.promisify(data.getLength).call(data);
17487
17112
  Number.isFinite(knownLength) && knownLength >= 0 && headers.setContentLength(knownLength);
17488
17113
  /*eslint no-empty:0*/
17489
17114
  } catch (e) {
@@ -17611,7 +17236,7 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17611
17236
  if (config.transport) {
17612
17237
  transport = config.transport;
17613
17238
  } else if (config.maxRedirects === 0) {
17614
- transport = isHttpsRequest ? require$$4$1 : require$$3$1;
17239
+ transport = isHttpsRequest ? require$$4 : require$$3;
17615
17240
  } else {
17616
17241
  if (config.maxRedirects) {
17617
17242
  options.maxRedirects = config.maxRedirects;
@@ -19544,5 +19169,5 @@ async function dataLink(data, schema) {
19544
19169
  return isArray ? result : result[0];
19545
19170
  }
19546
19171
 
19547
- export { DataLinkError, callService, dataLink, deregisterService, getRandomServiceInstance, getServiceInstances, getServiceUrl, listServices, registerService };
19172
+ export { DataLinkError, callService, dataLink, deregisterService, getClient, getRandomServiceInstance, getServiceInstances, getServiceUrl, initClient, listServices, registerService };
19548
19173
  //# sourceMappingURL=index.esm.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-consul-service",
3
- "version": "1.0.43",
3
+ "version": "1.0.45",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "types": "dist/index.d.ts",