@attraccess/plugin-rabbitmq 0.1.0-nightly.944.1 → 0.1.0-nightly.980.1

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.js CHANGED
@@ -52,7 +52,8 @@ var TrustConfigurationError = class extends Error {
52
52
  };
53
53
  function managementApiBase(config) {
54
54
  const host = (0, import_node_net.isIP)(config.host) === 6 ? `[${config.host}]` : config.host;
55
- return `${config.useTls ? "https" : "http"}://${host}:${config.useTls ? 15671 : 15672}`;
55
+ const port = config.managementPort ?? (config.useTls ? 15671 : 15672);
56
+ return `${config.useTls ? "https" : "http"}://${host}:${port}`;
56
57
  }
57
58
  function trustOptions(config) {
58
59
  if (config.tlsInsecure) {
@@ -60,15 +61,16 @@ function trustOptions(config) {
60
61
  "RabbitMQ management requires certificate verification. Disable tlsInsecure and configure a trusted CA certificate."
61
62
  );
62
63
  }
63
- const servername = config.tlsServername;
64
+ const servername = config.tlsServername === "" ? void 0 : config.tlsServername;
64
65
  if (servername != null && (typeof servername !== "string" || servername.length > 253 || !servername.split(".").every((label) => /^[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?$/i.test(label)) || (0, import_node_net.isIP)(servername))) {
65
66
  throw new TrustConfigurationError(
66
67
  "TLS server name must be a DNS hostname matching the management certificate, without a scheme or port."
67
68
  );
68
69
  }
69
- if (config.caCert != null) {
70
+ const caCert = config.caCert === "" ? void 0 : config.caCert;
71
+ if (caCert != null) {
70
72
  try {
71
- const pem = config.caCert;
73
+ const pem = caCert;
72
74
  const certificates = typeof pem === "string" ? pem.match(/-----BEGIN CERTIFICATE-----[\s\S]*?-----END CERTIFICATE-----/g) : null;
73
75
  if (!certificates?.length || pem.replace(/-----BEGIN CERTIFICATE-----[\s\S]*?-----END CERTIFICATE-----/g, "").trim()) {
74
76
  throw new Error();
@@ -82,7 +84,7 @@ function trustOptions(config) {
82
84
  }
83
85
  return {
84
86
  rejectUnauthorized: true,
85
- ...config.caCert != null ? { ca: config.caCert } : {},
87
+ ...caCert != null ? { ca: caCert } : {},
86
88
  ...servername != null ? { servername } : {}
87
89
  };
88
90
  }
@@ -271,8 +273,8 @@ var RabbitmqDetectionService = class {
271
273
  };
272
274
  }
273
275
  // Builds the management API base URL from the generic MQTT config. The
274
- // management API runs on its own port, so we substitute the conventional
275
- // management port for the MQTT one and pick the scheme from useTls.
276
+ // management API uses its configured port or the provider default, independently
277
+ // of the MQTT port. The scheme still comes from useTls.
276
278
  managementApiBase(config) {
277
279
  return managementApiBase(config);
278
280
  }
@@ -341,7 +343,10 @@ var RabbitmqManagementClient = class {
341
343
  try {
342
344
  response = await managementRequest(config, `${base}/api${path}`, method, body, REQUEST_TIMEOUT_MS);
343
345
  } catch (error) {
344
- throw new import_common3.HttpException(describeManagementError(error, REQUEST_TIMEOUT_MS), import_common3.HttpStatus.BAD_GATEWAY);
346
+ throw new import_common3.HttpException(
347
+ `Cannot reach the RabbitMQ management API at ${base}: ${describeManagementError(error, REQUEST_TIMEOUT_MS)}`,
348
+ import_common3.HttpStatus.BAD_GATEWAY
349
+ );
345
350
  }
346
351
  if (!response.ok) {
347
352
  throw await this.toHttpException(response);
@@ -353,7 +358,7 @@ var RabbitmqManagementClient = class {
353
358
  // doesn't mistake them for an expired Attraccess session.
354
359
  async toHttpException(response) {
355
360
  const upstream = await this.parseErrorBody(response);
356
- const reason = typeof upstream?.reason === "string" ? upstream.reason : typeof upstream?.error === "string" ? upstream.error : "";
361
+ const reason = upstream?.reason || upstream?.error || "";
357
362
  if (response.status === 401) {
358
363
  return new import_common3.HttpException(
359
364
  "The RabbitMQ management API rejected the configured MQTT server credentials (401). Check the username/password configured for this MQTT server.",
@@ -370,10 +375,7 @@ var RabbitmqManagementClient = class {
370
375
  return new import_common3.HttpException("Not found on the RabbitMQ side.", import_common3.HttpStatus.NOT_FOUND);
371
376
  }
372
377
  if (response.status === 400) {
373
- return new import_common3.HttpException(
374
- "RabbitMQ rejected the request. Check the supplied management parameters.",
375
- import_common3.HttpStatus.BAD_REQUEST
376
- );
378
+ return new import_common3.HttpException("RabbitMQ rejected the request.", import_common3.HttpStatus.BAD_REQUEST);
377
379
  }
378
380
  return new import_common3.HttpException(
379
381
  `RabbitMQ management API request failed (HTTP ${response.status}).`,
@@ -401,6 +403,19 @@ var RabbitmqManagementClient = class {
401
403
  return null;
402
404
  }
403
405
  }
406
+ describeNetworkError(error) {
407
+ if (error instanceof Error) {
408
+ if (error.name === "AbortError") {
409
+ return `no response within ${REQUEST_TIMEOUT_MS}ms`;
410
+ }
411
+ const cause = error.cause;
412
+ if (cause instanceof Error && cause.message) {
413
+ return cause.message;
414
+ }
415
+ return error.message;
416
+ }
417
+ return "unknown network error";
418
+ }
404
419
  };
405
420
  RabbitmqManagementClient = __decorateClass([
406
421
  (0, import_common3.Injectable)()
@@ -178,7 +178,7 @@ function RabbitmqStatusPanel({ mqttServerId }) {
178
178
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
179
179
  className: "rmq:flex rmq:items-center rmq:gap-2",
180
180
  children: [
181
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RabbitIcon$1, { className: "rmq:w-5 rmq:h-5 rmq:text-primary" }),
181
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RabbitIcon$1, { className: "rmq:w-5 rmq:h-5 rmq:text-accent-soft-foreground" }),
182
182
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
183
183
  className: "rmq:text-base rmq:font-semibold rmq:text-default-700",
184
184
  children: "RabbitMQ"
@@ -753,7 +753,7 @@ function RabbitmqUserPanel({ mqttServerId }) {
753
753
  className: "rmq:flex rmq:flex-row rmq:items-center rmq:justify-between rmq:gap-2",
754
754
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
755
755
  className: "rmq:flex rmq:items-center rmq:gap-2",
756
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(UsersIcon, { className: "rmq:w-5 rmq:h-5 rmq:text-primary" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
756
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(UsersIcon, { className: "rmq:w-5 rmq:h-5 rmq:text-accent-soft-foreground" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
757
757
  className: "rmq:text-base rmq:font-semibold rmq:text-default-700",
758
758
  children: "RabbitMQ users"
759
759
  })]
@@ -946,7 +946,7 @@ function RabbitmqPage() {
946
946
  className: "rmq:flex rmq:flex-col rmq:gap-6 rmq:p-6 rmq:max-w-4xl rmq:mx-auto",
947
947
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
948
948
  className: "rmq:flex rmq:items-center rmq:gap-3",
949
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(RabbitIcon, { className: "rmq:w-6 rmq:h-6 rmq:text-primary" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", {
949
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(RabbitIcon, { className: "rmq:w-6 rmq:h-6 rmq:text-accent-soft-foreground" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", {
950
950
  className: "rmq:text-2xl rmq:font-semibold rmq:text-default-800",
951
951
  children: "RabbitMQ"
952
952
  })]
@@ -9,7 +9,7 @@ var exportSet = /* @__PURE__ */ new Set([
9
9
  ]);
10
10
  var moduleMap = { "./plugin": () => {
11
11
  dynamicLoadingCss(["style.css"], false, "./plugin");
12
- return __federation_import("./__federation_expose_Plugin-msF9B5xa.js").then((module) => Object.keys(module).every((item) => exportSet.has(item)) ? () => module.default : () => module);
12
+ return __federation_import("./__federation_expose_Plugin-ytcRKNWl.js").then((module) => Object.keys(module).every((item) => exportSet.has(item)) ? () => module.default : () => module);
13
13
  } };
14
14
  var seen = {};
15
15
  var dynamicLoadingCss = (cssFilePaths, dontAppendStylesToHead, exposeItemName) => {
@@ -198,6 +198,10 @@
198
198
  white-space: nowrap;
199
199
  }
200
200
 
201
+ .rmq\:text-accent-soft-foreground {
202
+ color: var(--accent-soft-foreground);
203
+ }
204
+
201
205
  .rmq\:text-danger {
202
206
  color: var(--danger);
203
207
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@attraccess/plugin-rabbitmq",
3
- "version": "0.1.0-nightly.944.1",
3
+ "version": "0.1.0-nightly.980.1",
4
4
  "description": "Official Attraccess integration for RabbitMQ.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {