@oxy.so/core 1.6.0 → 1.6.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.
@@ -5,6 +5,12 @@ const trafficNodeHttp_1 = require("./trafficNodeHttp");
5
5
  const socket_1 = require("@oxy.so/telemetry/socket");
6
6
  const node_crypto_1 = require("node:crypto");
7
7
  const OxyServices_1 = require("../OxyServices");
8
+ // Static, unlike the lazy import in `mixins/OxyServices.auth.ts`: that module is
9
+ // reachable from the root barrel, which ships to React Native, so pulling
10
+ // `node:crypto` in eagerly there would cost every mobile bundle. This file is
11
+ // server-only and the server barrel already exports `./workloadIdentity`, so
12
+ // there is nothing here for a phone to load.
13
+ const workloadIdentity_1 = require("./workloadIdentity");
8
14
  const collector_1 = require("@oxy.so/telemetry/collector");
9
15
  /** Install once per service process, before registering HTTP routes. */
10
16
  function createEcosystemTraffic(options) {
@@ -17,9 +23,30 @@ function createEcosystemTraffic(options) {
17
23
  }
18
24
  const apiKey = activityKey || process.env.OXY_SERVICE_API_KEY;
19
25
  const apiSecret = activitySecret || process.env.OXY_SERVICE_API_SECRET;
20
- if (!options.credential && (!apiKey || !apiSecret))
21
- throw new Error('Ecosystem activity requires OXY_SERVICE_API_KEY and OXY_SERVICE_API_SECRET');
26
+ /**
27
+ * Having no key pair is a legitimate configuration now — but only where this
28
+ * process can prove what it IS (ADR 0026).
29
+ *
30
+ * This used to throw on a missing pair, full stop. Every service in the fleet
31
+ * boots with `OXY_ECOSYSTEM_ACTIVITY_ENABLED=true`, so deleting
32
+ * `OXY_SERVICE_API_KEY` and `OXY_SERVICE_API_SECRET` from a task definition —
33
+ * which is the entire migration ADR 0026 asks for — killed the process at
34
+ * boot. The ECS circuit breaker then rolled the deploy back and reported the
35
+ * service stable, so the operator saw a rollback with nothing naming its
36
+ * cause. That is what one line cost, multiplied by fourteen services holding
37
+ * a secret they no longer need.
38
+ *
39
+ * What is still refused: nothing to authenticate with AND nothing to attest.
40
+ * That is a laptop or a CI box, where the container credentials endpoint is
41
+ * not going to turn up later, and the honest answer is to say so at boot
42
+ * rather than to fail on the first heartbeat.
43
+ */
44
+ if (!options.credential && (!apiKey || !apiSecret) && !(0, workloadIdentity_1.canAttestWorkloadIdentity)()) {
45
+ throw new Error('Ecosystem activity needs one of: an OXY_ACTIVITY_API_KEY and OXY_ACTIVITY_API_SECRET pair, an OXY_SERVICE_API_KEY and OXY_SERVICE_API_SECRET pair, or a workload identity this process can attest (ADR 0026).');
46
+ }
22
47
  const oxy = new OxyServices_1.OxyServices({ baseURL });
48
+ // Left unconfigured when there is no pair on purpose: `getServiceToken()`
49
+ // attests instead of being handed half a credential to fail on.
23
50
  if (apiKey && apiSecret)
24
51
  oxy.configureServiceAuth(apiKey, apiSecret);
25
52
  const credential = options.credential ?? (() => oxy.getServiceToken());