@ceon-oy/monitor-sdk 1.4.0 → 1.4.2

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/dist/index.d.mts CHANGED
@@ -306,6 +306,12 @@ declare class MonitorClient {
306
306
  * Fetch with timeout to prevent hanging requests
307
307
  */
308
308
  private fetchWithTimeout;
309
+ /**
310
+ * Perform an HTTPS request with TLS certificate verification disabled.
311
+ * Used for health checks on servers with self-signed certificates.
312
+ * Uses Node.js built-in `https` module — works reliably in bundled environments.
313
+ */
314
+ private fetchInsecureHttps;
309
315
  private sendSingle;
310
316
  private sendBatch;
311
317
  private startFlushTimer;
package/dist/index.d.ts CHANGED
@@ -306,6 +306,12 @@ declare class MonitorClient {
306
306
  * Fetch with timeout to prevent hanging requests
307
307
  */
308
308
  private fetchWithTimeout;
309
+ /**
310
+ * Perform an HTTPS request with TLS certificate verification disabled.
311
+ * Used for health checks on servers with self-signed certificates.
312
+ * Uses Node.js built-in `https` module — works reliably in bundled environments.
313
+ */
314
+ private fetchInsecureHttps;
309
315
  private sendSingle;
310
316
  private sendBatch;
311
317
  private startFlushTimer;
package/dist/index.js CHANGED
@@ -544,6 +544,45 @@ var MonitorClient = class {
544
544
  clearTimeout(timeoutId);
545
545
  }
546
546
  }
547
+ /**
548
+ * Perform an HTTPS request with TLS certificate verification disabled.
549
+ * Used for health checks on servers with self-signed certificates.
550
+ * Uses Node.js built-in `https` module — works reliably in bundled environments.
551
+ */
552
+ async fetchInsecureHttps(url, options, timeoutMs) {
553
+ const https = await import("https");
554
+ const parsed = new URL(url);
555
+ return new Promise((resolve, reject) => {
556
+ let req;
557
+ const timeoutId = setTimeout(() => {
558
+ req?.destroy();
559
+ reject(new Error(`Request timeout after ${timeoutMs}ms`));
560
+ }, timeoutMs);
561
+ req = https.request(
562
+ {
563
+ hostname: parsed.hostname,
564
+ port: parsed.port || 443,
565
+ path: parsed.pathname + parsed.search,
566
+ method: options.method || "GET",
567
+ headers: options.headers,
568
+ rejectUnauthorized: false
569
+ },
570
+ (res) => {
571
+ clearTimeout(timeoutId);
572
+ res.resume();
573
+ resolve({ status: res.statusCode || 0 });
574
+ }
575
+ );
576
+ req.on("error", (err) => {
577
+ clearTimeout(timeoutId);
578
+ reject(err);
579
+ });
580
+ if (options.body) {
581
+ req.write(options.body);
582
+ }
583
+ req.end();
584
+ });
585
+ }
547
586
  async sendSingle(error) {
548
587
  const response = await this.fetchWithTimeout(`${this.endpoint}/api/v1/errors`, {
549
588
  method: "POST",
@@ -1348,24 +1387,7 @@ var MonitorClient = class {
1348
1387
  "Content-Type": "application/json"
1349
1388
  };
1350
1389
  }
1351
- if (endpoint.allowInsecureTls) {
1352
- try {
1353
- const undici = await import(
1354
- /* webpackIgnore: true */
1355
- "undici"
1356
- );
1357
- const Agent = undici.Agent;
1358
- requestOptions.dispatcher = new Agent({
1359
- connect: { rejectUnauthorized: false }
1360
- });
1361
- } catch {
1362
- }
1363
- }
1364
- const response = await this.fetchWithTimeout(
1365
- endpoint.url,
1366
- requestOptions,
1367
- endpoint.timeoutMs
1368
- );
1390
+ const response = endpoint.allowInsecureTls && endpoint.url.startsWith("https") ? await this.fetchInsecureHttps(endpoint.url, requestOptions, endpoint.timeoutMs) : await this.fetchWithTimeout(endpoint.url, requestOptions, endpoint.timeoutMs);
1369
1391
  const responseTimeMs = Date.now() - startTime;
1370
1392
  const statusCode = response.status;
1371
1393
  let status;
package/dist/index.mjs CHANGED
@@ -508,6 +508,45 @@ var MonitorClient = class {
508
508
  clearTimeout(timeoutId);
509
509
  }
510
510
  }
511
+ /**
512
+ * Perform an HTTPS request with TLS certificate verification disabled.
513
+ * Used for health checks on servers with self-signed certificates.
514
+ * Uses Node.js built-in `https` module — works reliably in bundled environments.
515
+ */
516
+ async fetchInsecureHttps(url, options, timeoutMs) {
517
+ const https = await import("https");
518
+ const parsed = new URL(url);
519
+ return new Promise((resolve, reject) => {
520
+ let req;
521
+ const timeoutId = setTimeout(() => {
522
+ req?.destroy();
523
+ reject(new Error(`Request timeout after ${timeoutMs}ms`));
524
+ }, timeoutMs);
525
+ req = https.request(
526
+ {
527
+ hostname: parsed.hostname,
528
+ port: parsed.port || 443,
529
+ path: parsed.pathname + parsed.search,
530
+ method: options.method || "GET",
531
+ headers: options.headers,
532
+ rejectUnauthorized: false
533
+ },
534
+ (res) => {
535
+ clearTimeout(timeoutId);
536
+ res.resume();
537
+ resolve({ status: res.statusCode || 0 });
538
+ }
539
+ );
540
+ req.on("error", (err) => {
541
+ clearTimeout(timeoutId);
542
+ reject(err);
543
+ });
544
+ if (options.body) {
545
+ req.write(options.body);
546
+ }
547
+ req.end();
548
+ });
549
+ }
511
550
  async sendSingle(error) {
512
551
  const response = await this.fetchWithTimeout(`${this.endpoint}/api/v1/errors`, {
513
552
  method: "POST",
@@ -1312,24 +1351,7 @@ var MonitorClient = class {
1312
1351
  "Content-Type": "application/json"
1313
1352
  };
1314
1353
  }
1315
- if (endpoint.allowInsecureTls) {
1316
- try {
1317
- const undici = await import(
1318
- /* webpackIgnore: true */
1319
- "undici"
1320
- );
1321
- const Agent = undici.Agent;
1322
- requestOptions.dispatcher = new Agent({
1323
- connect: { rejectUnauthorized: false }
1324
- });
1325
- } catch {
1326
- }
1327
- }
1328
- const response = await this.fetchWithTimeout(
1329
- endpoint.url,
1330
- requestOptions,
1331
- endpoint.timeoutMs
1332
- );
1354
+ const response = endpoint.allowInsecureTls && endpoint.url.startsWith("https") ? await this.fetchInsecureHttps(endpoint.url, requestOptions, endpoint.timeoutMs) : await this.fetchWithTimeout(endpoint.url, requestOptions, endpoint.timeoutMs);
1333
1355
  const responseTimeMs = Date.now() - startTime;
1334
1356
  const statusCode = response.status;
1335
1357
  let status;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ceon-oy/monitor-sdk",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "Client SDK for Ceon Monitor - Error tracking, health monitoring, security events, and vulnerability scanning",
5
5
  "author": "Ceon",
6
6
  "license": "MIT",