@sockethub/server 5.0.0-alpha.23 → 5.0.0-alpha.24

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
@@ -10027,7 +10027,10 @@ function errorMessage(value) {
10027
10027
  }
10028
10028
  return String(value);
10029
10029
  }
10030
- var init_error = () => {};
10030
+ var EXPECTED_ERROR;
10031
+ var init_error = __esm(() => {
10032
+ EXPECTED_ERROR = Symbol.for("sockethub.expectedError");
10033
+ });
10031
10034
 
10032
10035
  // src/version.ts
10033
10036
  import { createRequire as createRequire2 } from "node:module";
@@ -16586,7 +16589,7 @@ var init_package = __esm(() => {
16586
16589
  package_default = {
16587
16590
  name: "@sockethub/schemas",
16588
16591
  description: "JSON schema files for validating Sockethub Activity Streams",
16589
- version: "3.0.0-alpha.23",
16592
+ version: "3.0.0-alpha.24",
16590
16593
  type: "module",
16591
16594
  private: false,
16592
16595
  author: "Nick Jennings <nick@silverbucket.net>",
@@ -16656,7 +16659,7 @@ var init_package = __esm(() => {
16656
16659
  "ajv-formats": "^2.1.1",
16657
16660
  "ajv-formats-draft2019": "^1.6.1"
16658
16661
  },
16659
- gitHead: "a6d303097640e82c7d1a7cef6dea2e6dae5f2cac",
16662
+ gitHead: "e778256d7067e2743cd6807a15d39a0cc65a358d",
16660
16663
  types: "./dist/index.d.ts"
16661
16664
  };
16662
16665
  });
@@ -66473,6 +66476,36 @@ var init_esm5 = __esm(() => {
66473
66476
  function setObservabilityAdapter(next) {
66474
66477
  adapter = next;
66475
66478
  }
66479
+ function startConnectionTelemetry() {
66480
+ const startedAt = performance.now();
66481
+ const platforms = new Set;
66482
+ let ended = false;
66483
+ observability.count("sockethub.connection.opened");
66484
+ return {
66485
+ recordPlatform(platform2) {
66486
+ if (ended || platforms.has(platform2)) {
66487
+ return;
66488
+ }
66489
+ platforms.add(platform2);
66490
+ observability.count("sockethub.platform_session.started", 1, {
66491
+ platform: platform2
66492
+ });
66493
+ },
66494
+ end() {
66495
+ if (ended) {
66496
+ return;
66497
+ }
66498
+ ended = true;
66499
+ observability.count("sockethub.connection.closed");
66500
+ observability.distribution("sockethub.connection.duration", performance.now() - startedAt, "millisecond");
66501
+ const classification = platforms.size === 0 ? "inactive" : platforms.size === 1 ? "single_platform" : "multi_platform";
66502
+ observability.count("sockethub.connection.classified", 1, {
66503
+ classification
66504
+ });
66505
+ observability.distribution("sockethub.connection.platform_count", platforms.size, "none");
66506
+ }
66507
+ };
66508
+ }
66476
66509
  function redactObservabilityLog(message) {
66477
66510
  return message.replace(/https?:\/\/\S+/gi, "[url]").replace(/\b[\w.+-]+@[\w.-]+\.[a-z]{2,}\b/gi, "[address]").replace(/\b(?:\d{1,3}\.){3}\d{1,3}\b/g, "[ip]").replace(/\b[0-9a-f]{0,4}:[0-9a-f:]{2,}\b/gi, "[ip]");
66478
66511
  }
@@ -66492,12 +66525,14 @@ var init_observability = __esm(() => {
66492
66525
  noopAdapter = {
66493
66526
  count: () => {},
66494
66527
  gauge: () => {},
66528
+ distribution: () => {},
66495
66529
  startAction: () => () => {}
66496
66530
  };
66497
66531
  adapter = noopAdapter;
66498
66532
  observability = {
66499
66533
  count: (...args) => adapter.count(...args),
66500
66534
  gauge: (...args) => adapter.gauge(...args),
66535
+ distribution: (...args) => adapter.distribution(...args),
66501
66536
  startAction: (...args) => adapter.startAction(...args)
66502
66537
  };
66503
66538
  });
@@ -71460,6 +71495,7 @@ var exports_sentry = {};
71460
71495
  __export(exports_sentry, {
71461
71496
  SENTRY_FLUSH_TIMEOUT_MS: () => SENTRY_FLUSH_TIMEOUT_MS,
71462
71497
  count: () => count2,
71498
+ distribution: () => distribution2,
71463
71499
  flush: () => flush3,
71464
71500
  gauge: () => gauge2,
71465
71501
  reportError: () => reportError,
@@ -71483,9 +71519,14 @@ function gauge2(name, value, attributes = {}) {
71483
71519
  exports_public_api.gauge(name, value, { attributes });
71484
71520
  }
71485
71521
  }
71486
- function startAction(platform3, action) {
71522
+ function distribution2(name, value, unit, attributes = {}) {
71523
+ if (sentryConfig.enableMetrics) {
71524
+ exports_public_api.distribution(name, value, { unit, attributes });
71525
+ }
71526
+ }
71527
+ function startAction(platform3, action, additionalAttributes = {}) {
71487
71528
  const startedAt = performance.now();
71488
- const attributes = { platform: platform3, action };
71529
+ const attributes = { platform: platform3, action, ...additionalAttributes };
71489
71530
  count2("sockethub.action.started", 1, attributes);
71490
71531
  const span = startInactiveSpan({
71491
71532
  name: `${platform3}.${action}`,
@@ -71497,12 +71538,7 @@ function startAction(platform3, action) {
71497
71538
  span.setStatus({ code: error4 ? 2 : 1 });
71498
71539
  span.end();
71499
71540
  count2(error4 ? "sockethub.action.failed" : "sockethub.action.completed", 1, attributes);
71500
- if (sentryConfig.enableMetrics) {
71501
- exports_public_api.distribution("sockethub.action.duration", duration, {
71502
- unit: "millisecond",
71503
- attributes
71504
- });
71505
- }
71541
+ distribution2("sockethub.action.duration", duration, "millisecond", attributes);
71506
71542
  };
71507
71543
  }
71508
71544
  async function sendTestEvent() {
@@ -71555,7 +71591,7 @@ var init_sentry = __esm(async () => {
71555
71591
  setTag("service", "sockethub");
71556
71592
  setTag("process", process.env.SOCKETHUB_PLATFORM_CHILD === "1" ? "platform" : "server");
71557
71593
  logger2.info("initialized sentry observability");
71558
- setObservabilityAdapter({ count: count2, gauge: gauge2, startAction });
71594
+ setObservabilityAdapter({ count: count2, gauge: gauge2, distribution: distribution2, startAction });
71559
71595
  });
71560
71596
 
71561
71597
  // ../util/dist/crypto/index.js
@@ -137931,7 +137967,7 @@ var require_package2 = __commonJS(function(exports, module) {
137931
137967
  module.exports = {
137932
137968
  name: "@sockethub/server",
137933
137969
  description: "A polyglot messaging service, server libraries",
137934
- version: "5.0.0-alpha.23",
137970
+ version: "5.0.0-alpha.24",
137935
137971
  type: "module",
137936
137972
  private: false,
137937
137973
  author: "Nick Jennings <nick@silverbucket.net>",
@@ -137982,11 +138018,11 @@ var require_package2 = __commonJS(function(exports, module) {
137982
138018
  dependencies: {
137983
138019
  "@sentry/node": "^10.36.0",
137984
138020
  "@sentry/profiling-node": "10.36.0",
137985
- "@sockethub/client": "^5.0.0-alpha.23",
137986
- "@sockethub/data-layer": "^1.0.0-alpha.23",
137987
- "@sockethub/logger": "^1.0.0-alpha.23",
137988
- "@sockethub/schemas": "^3.0.0-alpha.23",
137989
- "@sockethub/util": "^1.0.0-alpha.11",
138021
+ "@sockethub/client": "^5.0.0-alpha.24",
138022
+ "@sockethub/data-layer": "^1.0.0-alpha.24",
138023
+ "@sockethub/logger": "^1.0.0-alpha.24",
138024
+ "@sockethub/schemas": "^3.0.0-alpha.24",
138025
+ "@sockethub/util": "^1.0.0-alpha.12",
137990
138026
  chalk: "^5.6.2",
137991
138027
  convict: "^6.2.5",
137992
138028
  ejs: "^3.1.10",
@@ -138017,16 +138053,16 @@ var require_package2 = __commonJS(function(exports, module) {
138017
138053
  "web-streams-polyfill": "^3.3.3"
138018
138054
  },
138019
138055
  optionalDependencies: {
138020
- "@sockethub/examples": "^1.0.0-alpha.23",
138021
- "@sockethub/platform-caldav": "^1.0.0-alpha.7",
138022
- "@sockethub/platform-carddav": "^1.0.0-alpha.4",
138023
- "@sockethub/platform-dummy": "^3.0.0-alpha.23",
138024
- "@sockethub/platform-feeds": "^4.0.0-alpha.23",
138025
- "@sockethub/platform-irc": "^4.0.0-alpha.23",
138026
- "@sockethub/platform-metadata": "^1.0.1-alpha.18",
138027
- "@sockethub/platform-xmpp": "^5.0.0-alpha.23"
138028
- },
138029
- gitHead: "a6d303097640e82c7d1a7cef6dea2e6dae5f2cac",
138056
+ "@sockethub/examples": "^1.0.0-alpha.24",
138057
+ "@sockethub/platform-caldav": "^1.0.0-alpha.8",
138058
+ "@sockethub/platform-carddav": "^1.0.0-alpha.5",
138059
+ "@sockethub/platform-dummy": "^3.0.0-alpha.24",
138060
+ "@sockethub/platform-feeds": "^4.0.0-alpha.24",
138061
+ "@sockethub/platform-irc": "^4.0.0-alpha.24",
138062
+ "@sockethub/platform-metadata": "^1.0.1-alpha.19",
138063
+ "@sockethub/platform-xmpp": "^5.0.0-alpha.24"
138064
+ },
138065
+ gitHead: "e778256d7067e2743cd6807a15d39a0cc65a358d",
138030
138066
  types: "./dist/index.d.ts"
138031
138067
  };
138032
138068
  });
@@ -196701,11 +196737,16 @@ function createMessageHandlers(options) {
196701
196737
  credentialsStore,
196702
196738
  clientIp,
196703
196739
  platformSessionId,
196704
- onPlatformInstance
196740
+ onPlatformInstance,
196741
+ transport = "socket",
196742
+ onPlatformAction
196705
196743
  } = options;
196706
196744
  const credentials = middleware("credentials").use(normalizeActivityStreamMiddleware).use(validate("credentials", sessionId)).use(storeCredentials(credentialsStore, sessionId)).use((data, next) => {
196707
196745
  const platform3 = resolvePlatformId(data) ?? "unknown";
196708
- observability.startAction(platform3, "credentials")();
196746
+ onPlatformAction?.(platform3, "credentials");
196747
+ observability.startAction(platform3, "credentials", {
196748
+ transport
196749
+ })();
196709
196750
  next(data);
196710
196751
  }).use((err, data, next) => {
196711
196752
  next(attachError(err, data));
@@ -196723,7 +196764,10 @@ function createMessageHandlers(options) {
196723
196764
  next(attachError("unable to resolve platform from @context", msg));
196724
196765
  return;
196725
196766
  }
196726
- const finish = observability.startAction(platformId, msg.type);
196767
+ onPlatformAction?.(platformId, msg.type);
196768
+ const finish = observability.startAction(platformId, msg.type, {
196769
+ transport
196770
+ });
196727
196771
  let platformInstance;
196728
196772
  try {
196729
196773
  platformInstance = await processManager.get(platformId, msg.actor.id, platformSessionId, clientIp, sessionId);
@@ -197162,6 +197206,7 @@ function registerHttpActionsRoutes(app, options, deps = {}) {
197162
197206
  sessionId,
197163
197207
  sessionSecret,
197164
197208
  credentialsStore,
197209
+ transport: "http",
197165
197210
  onPlatformInstance: (platformInstance) => {
197166
197211
  if (!platformInstance.config.persist) {
197167
197212
  return;
@@ -198253,7 +198298,7 @@ class Sockethub {
198253
198298
  return;
198254
198299
  }
198255
198300
  this.activeConnections += 1;
198256
- observability.count("sockethub.connection.opened");
198301
+ const connectionTelemetry = startConnectionTelemetry();
198257
198302
  observability.gauge("sockethub.connection.active", this.activeConnections);
198258
198303
  const credentialsStore = new CredentialsStore(this.parentId, socket.id, crypto.deriveSecret(this.parentSecret1, sessionSecret), config_default.get("redis"), { ttlMs: getCredentialsTtlMs() });
198259
198304
  sessionLog.debug("socket.io connection");
@@ -198280,7 +198325,7 @@ class Sockethub {
198280
198325
  clearSessionScopes(socket.id);
198281
198326
  this.releaseIpSlot(clientIp);
198282
198327
  this.activeConnections = Math.max(0, this.activeConnections - 1);
198283
- observability.count("sockethub.connection.closed");
198328
+ connectionTelemetry.end();
198284
198329
  observability.gauge("sockethub.connection.active", this.activeConnections);
198285
198330
  });
198286
198331
  const handlers2 = createMessageHandlers({
@@ -198289,7 +198334,9 @@ class Sockethub {
198289
198334
  sessionSecret,
198290
198335
  credentialsStore,
198291
198336
  clientIp,
198292
- platformSessionId: socket.id
198337
+ platformSessionId: socket.id,
198338
+ transport: "socket",
198339
+ onPlatformAction: (platform3) => connectionTelemetry.recordPlatform(platform3)
198293
198340
  });
198294
198341
  socket.on("credentials", handlers2.credentials);
198295
198342
  socket.on("message", handlers2.message);
@@ -198534,4 +198581,4 @@ export {
198534
198581
  server
198535
198582
  };
198536
198583
 
198537
- //# debugId=9F3065D52CC919F464756E2164756E21
198584
+ //# debugId=55027E92341AB74264756E2164756E21