@camunda8/orchestration-cluster-api 10.0.3 → 10.1.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [10.1.0](https://github.com/camunda/orchestration-cluster-api-js/compare/v10.0.3...v10.1.0) (2026-11-19)
2
+
3
+
4
+ ### Features
5
+
6
+ * send attributable user-agent on rest and oauth requests (backport [#694](https://github.com/camunda/orchestration-cluster-api-js/issues/694) to stable/10) ([#695](https://github.com/camunda/orchestration-cluster-api-js/issues/695)) ([bc86feb](https://github.com/camunda/orchestration-cluster-api-js/commit/bc86febb7bc2b52066b956d8717eaf616af369b4))
7
+
1
8
  ## [10.0.3](https://github.com/camunda/orchestration-cluster-api-js/compare/v10.0.2...v10.0.3) (2026-11-19)
2
9
 
3
10
 
@@ -254,7 +254,7 @@ import {
254
254
  updateTenantClusterVariable,
255
255
  updateUser,
256
256
  updateUserTask
257
- } from "./chunk-G2GYAVRZ.js";
257
+ } from "./chunk-UQZHR5EN.js";
258
258
 
259
259
  // src/runtime/pagination.ts
260
260
  function abortError() {
@@ -2306,4 +2306,4 @@ export {
2306
2306
  CamundaClientBase,
2307
2307
  CamundaClient
2308
2308
  };
2309
- //# sourceMappingURL=chunk-QM3ZDYZC.js.map
2309
+ //# sourceMappingURL=chunk-JTOYRGYR.js.map
@@ -1187,8 +1187,40 @@ var createClient = (config = {}) => {
1187
1187
  };
1188
1188
  };
1189
1189
 
1190
- // src/runtime/auth.ts
1190
+ // src/runtime/version.ts
1191
+ var packageVersion = "10.1.0";
1192
+
1193
+ // src/runtime/userAgent.ts
1191
1194
  import { node } from "#platform";
1195
+ var SDK_USER_AGENT = `camunda-orchestration-sdk-js/${packageVersion}`;
1196
+ function userAgentHeaderName() {
1197
+ return node ? "User-Agent" : null;
1198
+ }
1199
+ function buildUserAgent(appUserAgent) {
1200
+ const extra = appUserAgent?.trim();
1201
+ return extra ? `${SDK_USER_AGENT} ${extra}` : SDK_USER_AGENT;
1202
+ }
1203
+ function userAgentHeaders(appUserAgent, name = userAgentHeaderName()) {
1204
+ return name ? { [name]: buildUserAgent(appUserAgent) } : {};
1205
+ }
1206
+ function withUserAgent(base, getAppUserAgent, name = userAgentHeaderName()) {
1207
+ return (input, init) => {
1208
+ const fetchImpl = base ?? ((i, n) => fetch(i, n));
1209
+ if (!name) return fetchImpl(input, init);
1210
+ const value = buildUserAgent(getAppUserAgent());
1211
+ if (!init?.headers && typeof Request !== "undefined" && input instanceof Request) {
1212
+ const headers2 = new Headers(input.headers);
1213
+ headers2.set(name, value);
1214
+ return fetchImpl(new Request(input, { headers: headers2 }), init);
1215
+ }
1216
+ const headers = new Headers(init?.headers);
1217
+ headers.set(name, value);
1218
+ return fetchImpl(input, { ...init || {}, headers });
1219
+ };
1220
+ }
1221
+
1222
+ // src/runtime/auth.ts
1223
+ import { node as node2 } from "#platform";
1192
1224
  var CamundaAuthError = class extends Error {
1193
1225
  constructor(code, message, cause) {
1194
1226
  super(`${code}: ${message}`);
@@ -1246,9 +1278,9 @@ var OAuthManager = class {
1246
1278
  } catch {
1247
1279
  }
1248
1280
  }
1249
- if (!this.session && this.cfg.oauth.cacheDir && node && this.isNode()) {
1281
+ if (!this.session && this.cfg.oauth.cacheDir && node2 && this.isNode()) {
1250
1282
  try {
1251
- const { fs, path } = node;
1283
+ const { fs, path } = node2;
1252
1284
  const file = path.join(this.cfg.oauth.cacheDir, `${this.storageKey}.json`);
1253
1285
  if (fs.existsSync(file)) {
1254
1286
  const raw = fs.readFileSync(file, "utf8");
@@ -1265,9 +1297,9 @@ var OAuthManager = class {
1265
1297
  this.session.setItem(this.storageKey, JSON.stringify(this.token));
1266
1298
  } catch {
1267
1299
  }
1268
- } else if (this.cfg.oauth.cacheDir && node && this.isNode()) {
1300
+ } else if (this.cfg.oauth.cacheDir && node2 && this.isNode()) {
1269
1301
  try {
1270
- const { fs, path } = node;
1302
+ const { fs, path } = node2;
1271
1303
  if (!fs.existsSync(this.cfg.oauth.cacheDir))
1272
1304
  fs.mkdirSync(this.cfg.oauth.cacheDir, { recursive: true });
1273
1305
  const file = path.join(this.cfg.oauth.cacheDir, `${this.storageKey}.json`);
@@ -1320,9 +1352,9 @@ var OAuthManager = class {
1320
1352
  if (opts.disk) {
1321
1353
  if (this.session) {
1322
1354
  this.session.removeItem(this.storageKey);
1323
- } else if (this.cfg.oauth.cacheDir && node && this.isNode()) {
1355
+ } else if (this.cfg.oauth.cacheDir && node2 && this.isNode()) {
1324
1356
  try {
1325
- const { fs, path } = node;
1357
+ const { fs, path } = node2;
1326
1358
  const file = path.join(this.cfg.oauth.cacheDir, `${this.storageKey}.json`);
1327
1359
  if (fs.existsSync(file)) fs.unlinkSync(file);
1328
1360
  } catch {
@@ -1370,7 +1402,10 @@ var OAuthManager = class {
1370
1402
  this.logger.debug(`OAuth token attempt ${attempt + 1}/${max}`);
1371
1403
  const res = await fetcher(this.cfg.oauth.oauthUrl, {
1372
1404
  method: "POST",
1373
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
1405
+ headers: {
1406
+ "Content-Type": "application/x-www-form-urlencoded",
1407
+ ...userAgentHeaders(this.cfg.userAgent)
1408
+ },
1374
1409
  body: body.toString(),
1375
1410
  signal: controller.signal
1376
1411
  });
@@ -1528,9 +1563,9 @@ function createAuthFacade(config, opts) {
1528
1563
  else if (cfg.auth.strategy === "BASIC") basic = new BasicAuthManager(cfg);
1529
1564
  const fetcher = (input, init) => opts?.fetch ? opts.fetch(input, init) : fetch(input, init);
1530
1565
  let nodeAgent = null;
1531
- if (cfg.mtls && node && typeof process !== "undefined" && process.versions?.node) {
1566
+ if (cfg.mtls && node2 && typeof process !== "undefined" && process.versions?.node) {
1532
1567
  try {
1533
- const { fs, https } = node;
1568
+ const { fs, https } = node2;
1534
1569
  const material = {};
1535
1570
  const pem = (inline, path) => inline || (path ? fs.readFileSync(path, "utf8") : inline);
1536
1571
  if (cfg.mtls.cert || cfg.mtls.certPath) material.cert = pem(cfg.mtls.cert, cfg.mtls.certPath);
@@ -1951,9 +1986,6 @@ async function executeWithHttpRetry(fn, policy, logger, classify = defaultHttpCl
1951
1986
  return exec(fn, classify);
1952
1987
  }
1953
1988
 
1954
- // src/runtime/version.ts
1955
- var packageVersion = "10.0.3";
1956
-
1957
1989
  // src/runtime/configSchema.ts
1958
1990
  var SCHEMA = {
1959
1991
  CAMUNDA_REST_ADDRESS: {
@@ -2048,6 +2080,10 @@ var SCHEMA = {
2048
2080
  doc: "Basic auth password (required when CAMUNDA_AUTH_STRATEGY=BASIC).",
2049
2081
  requiredWhen: { key: "CAMUNDA_AUTH_STRATEGY", equals: "BASIC" }
2050
2082
  },
2083
+ CAMUNDA_USER_AGENT: {
2084
+ type: "string",
2085
+ doc: "Application user agent appended after the SDK identifier (camunda-orchestration-sdk-js/<version>) in the User-Agent header. Never replaces the SDK identifier."
2086
+ },
2051
2087
  CAMUNDA_SDK_VALIDATION: {
2052
2088
  type: "string",
2053
2089
  default: "req:none,res:none",
@@ -2210,7 +2246,7 @@ function allKeys() {
2210
2246
  }
2211
2247
 
2212
2248
  // src/runtime/supportLogger.ts
2213
- import { node as node2 } from "#platform";
2249
+ import { node as node3 } from "#platform";
2214
2250
  var NoopSupportLogger = class {
2215
2251
  log(_message, _addTimestamp = true) {
2216
2252
  }
@@ -2259,9 +2295,9 @@ var CamundaSupportLogger = class {
2259
2295
  constructor(config) {
2260
2296
  const enabled = !!config.supportLog?.enabled;
2261
2297
  this.enabled = enabled;
2262
- this.filepath = config.supportLog?.filePath || (node2 && typeof process !== "undefined" ? node2.path.join(process.cwd(), "camunda-support.log") : "camunda-support.log");
2263
- if (!this.enabled || !isNode() || !node2) return;
2264
- const { fs } = node2;
2298
+ this.filepath = config.supportLog?.filePath || (node3 && typeof process !== "undefined" ? node3.path.join(process.cwd(), "camunda-support.log") : "camunda-support.log");
2299
+ if (!this.enabled || !isNode() || !node3) return;
2300
+ const { fs } = node3;
2265
2301
  if (fs.existsSync(this.filepath)) {
2266
2302
  let n = 1;
2267
2303
  const base = this.filepath;
@@ -2278,8 +2314,8 @@ var CamundaSupportLogger = class {
2278
2314
  writeSupportLogPreamble(this, config);
2279
2315
  }
2280
2316
  log(message, addTimestamp = true) {
2281
- if (!this.enabled || !isNode() || !node2) return;
2282
- const { fs } = node2;
2317
+ if (!this.enabled || !isNode() || !node3) return;
2318
+ const { fs } = node3;
2283
2319
  const msg = typeof message === "object" ? safeStringify(message) : String(message);
2284
2320
  const line = addTimestamp ? `[${(/* @__PURE__ */ new Date()).toISOString()}]: ${msg}
2285
2321
  ` : `${msg}
@@ -2322,8 +2358,8 @@ function writeSupportLogPreamble(logger, config) {
2322
2358
  );
2323
2359
  logger.log(`Camunda SDK version: ${packageVersion}`, false);
2324
2360
  try {
2325
- if (!node2) throw new Error("node:os unavailable");
2326
- const { os } = node2;
2361
+ if (!node3) throw new Error("node:os unavailable");
2362
+ const { os } = node3;
2327
2363
  const osInfo = {
2328
2364
  platform: os.platform(),
2329
2365
  release: os.release(),
@@ -2699,7 +2735,7 @@ async function withCorrelation(id, fn) {
2699
2735
 
2700
2736
  // src/runtime/unifiedConfiguration.ts
2701
2737
  import { createEnv } from "typed-env";
2702
- import { node as node3 } from "#platform";
2738
+ import { node as node4 } from "#platform";
2703
2739
  var CamundaConfigurationError = class extends Error {
2704
2740
  errors;
2705
2741
  constructor(errors) {
@@ -3056,6 +3092,14 @@ function hydrateConfig(options = {}) {
3056
3092
  message: "CAMUNDA_MTLS_KEY_PASSPHRASE is set but no client key was provided."
3057
3093
  });
3058
3094
  }
3095
+ const userAgentRaw = rawMap.CAMUNDA_USER_AGENT?.trim();
3096
+ if (userAgentRaw && !/^[\t\x20-\x7E\x80-\xFF]*$/.test(userAgentRaw)) {
3097
+ errors.push({
3098
+ code: "CONFIG_INVALID_VALUE" /* CONFIG_INVALID_VALUE */,
3099
+ key: "CAMUNDA_USER_AGENT",
3100
+ message: "CAMUNDA_USER_AGENT is not a valid HTTP header value: it must contain only printable Latin-1 characters (no control characters such as CR/LF, and no characters above U+00FF)."
3101
+ });
3102
+ }
3059
3103
  const validationRaw = reqStr("CAMUNDA_SDK_VALIDATION");
3060
3104
  const validation = parseValidation(validationRaw, errors);
3061
3105
  if (errors.length) {
@@ -3196,6 +3240,7 @@ function hydrateConfig(options = {}) {
3196
3240
  },
3197
3241
  validation: { req: validation.req, res: validation.res, raw: validation.raw },
3198
3242
  logLevel: reqStr("CAMUNDA_SDK_LOG_LEVEL"),
3243
+ userAgent: rawMap.CAMUNDA_USER_AGENT?.trim() || void 0,
3199
3244
  eventual: {
3200
3245
  pollDefaultMs: reqInt("CAMUNDA_SDK_EVENTUAL_POLL_DEFAULT_MS")
3201
3246
  },
@@ -3214,7 +3259,7 @@ function hydrateConfig(options = {}) {
3214
3259
  },
3215
3260
  supportLog: {
3216
3261
  enabled: reqBool("CAMUNDA_SUPPORT_LOG_ENABLED"),
3217
- filePath: rawMap.CAMUNDA_SUPPORT_LOG_FILE_PATH || (node3 && typeof process !== "undefined" && typeof process.cwd === "function" ? node3.path.join(process.cwd(), "camunda-support.log") : "camunda-support.log")
3262
+ filePath: rawMap.CAMUNDA_SUPPORT_LOG_FILE_PATH || (node4 && typeof process !== "undefined" && typeof process.cwd === "function" ? node4.path.join(process.cwd(), "camunda-support.log") : "camunda-support.log")
3218
3263
  },
3219
3264
  workerDefaults: rawMap.CAMUNDA_WORKER_TIMEOUT || rawMap.CAMUNDA_WORKER_MAX_CONCURRENT_JOBS || rawMap.CAMUNDA_WORKER_REQUEST_TIMEOUT || rawMap.CAMUNDA_WORKER_NAME || rawMap.CAMUNDA_WORKER_STARTUP_JITTER_MAX_SECONDS ? {
3220
3265
  jobTimeoutMs: rawMap.CAMUNDA_WORKER_TIMEOUT ? parseInt(rawMap.CAMUNDA_WORKER_TIMEOUT, 10) : void 0,
@@ -3484,7 +3529,7 @@ async function applySchemaValidation(opts) {
3484
3529
 
3485
3530
  // src/runtime/validationExtras.ts
3486
3531
  import { ZodObject as ZodObject2 } from "zod";
3487
- import { node as node4 } from "#platform";
3532
+ import { node as node5 } from "#platform";
3488
3533
  var seenCaptures = /* @__PURE__ */ new Set();
3489
3534
  function hash(str) {
3490
3535
  let h = 0, i = 0;
@@ -3529,8 +3574,8 @@ function detectExtrasAndMaybeThrow(opts) {
3529
3574
  }
3530
3575
  if (settings.captureDir) {
3531
3576
  try {
3532
- if (!node4) throw new Error("node:fs unavailable");
3533
- const { fs, path: pathMod } = node4;
3577
+ if (!node5) throw new Error("node:fs unavailable");
3578
+ const { fs, path: pathMod } = node5;
3534
3579
  if (!fs.existsSync(settings.captureDir))
3535
3580
  fs.mkdirSync(settings.captureDir, { recursive: true, mode: 448 });
3536
3581
  const sig = `${operationId}|${flatIssues.sort().join("|")}`;
@@ -3713,7 +3758,7 @@ var CamundaCore = class _CamundaCore {
3713
3758
  });
3714
3759
  const baseFetch = opts.fetch;
3715
3760
  this._baseFetch = baseFetch;
3716
- this._fetch = baseFetch;
3761
+ this._fetch = withUserAgent(baseFetch, () => this._config.userAgent);
3717
3762
  if (opts.telemetry) {
3718
3763
  this._fetch = wrapFetch(this._fetch || fetch, {
3719
3764
  hooks: opts.telemetry.hooks,
@@ -3825,11 +3870,12 @@ var CamundaCore = class _CamundaCore {
3825
3870
  }
3826
3871
  // Merge new overrides and re-hydrate.
3827
3872
  configure(next) {
3828
- if (next.config) this._setOverrides({ ...this._getOverrides(), ...next.config });
3829
- if (next.fetch) this._baseFetch = next.fetch;
3830
- this._fetch = this._baseFetch;
3831
- const { config } = hydrateConfig({ overrides: this._getOverrides(), env: next.env });
3873
+ const candidate = next.config ? { ...this._getOverrides(), ...next.config } : this._getOverrides();
3874
+ const { config } = hydrateConfig({ overrides: candidate, env: next.env });
3875
+ if (next.config) this._setOverrides(candidate);
3832
3876
  this._config = deepFreeze2(config);
3877
+ if (next.fetch) this._baseFetch = next.fetch;
3878
+ this._fetch = withUserAgent(this._baseFetch, () => this._config.userAgent);
3833
3879
  if (next.telemetry) {
3834
3880
  this._fetch = wrapFetch(this._fetch || fetch, {
3835
3881
  hooks: next.telemetry.hooks,
@@ -21382,4 +21428,4 @@ export {
21382
21428
  updateUser2 as updateUser,
21383
21429
  updateUserTask2 as updateUserTask
21384
21430
  };
21385
- //# sourceMappingURL=chunk-G2GYAVRZ.js.map
21431
+ //# sourceMappingURL=chunk-UQZHR5EN.js.map