@backstage/backend-app-api 0.7.3-next.1 → 0.7.3

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,5 +1,32 @@
1
1
  # @backstage/backend-app-api
2
2
 
3
+ ## 0.7.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 4cd5ff0: Add ability to configure the Node.js HTTP Server when configuring the root HTTP Router service
8
+ - e8199b1: Move the JWKS registration outside of the lifecycle middleware
9
+ - d229dc4: Move path utilities from `backend-common` to the `backend-plugin-api` package.
10
+ - dc8c5dd: The default `TokenManager` implementation no longer requires keys to be configured in production, but it will throw an errors when generating or authenticating tokens. The default `AuthService` implementation will now also provide additional context if such an error is throw when falling back to using the `TokenManager` service to generate tokens for outgoing requests.
11
+ - 025641b: Redact `meta` fields too with the logger
12
+ - 09f8988: Remove explicit `alg` check for user tokens in `verifyToken`
13
+ - 5863e02: Internal refactor to only create one external token handler
14
+ - a1dc547: Added support for camel case CSP directives in app-config. For example:
15
+
16
+ ```yaml
17
+ backend:
18
+ csp:
19
+ upgradeInsecureRequests: false
20
+ ```
21
+
22
+ - 329cc34: Added logging of all plugins being initialized, periodic status, and completion.
23
+ - Updated dependencies
24
+ - @backstage/backend-common@0.22.0
25
+ - @backstage/backend-plugin-api@0.6.18
26
+ - @backstage/backend-tasks@0.5.23
27
+ - @backstage/plugin-auth-node@0.4.13
28
+ - @backstage/plugin-permission-node@0.7.29
29
+
3
30
  ## 0.7.2-next.1
4
31
 
5
32
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/backend-app-api",
3
- "version": "0.7.3-next.1",
3
+ "version": "0.7.3",
4
4
  "main": "../dist/alpha.cjs.js",
5
5
  "types": "../dist/alpha.d.ts"
6
6
  }
package/dist/index.cjs.js CHANGED
@@ -15,6 +15,7 @@ var cors = require('cors');
15
15
  var helmet = require('helmet');
16
16
  var morgan = require('morgan');
17
17
  var compression = require('compression');
18
+ var kebabCase = require('lodash/kebabCase');
18
19
  var minimatch = require('minimatch');
19
20
  var errors = require('@backstage/errors');
20
21
  var crypto = require('crypto');
@@ -22,11 +23,11 @@ var winston = require('winston');
22
23
  var backendPluginApi = require('@backstage/backend-plugin-api');
23
24
  var alpha = require('@backstage/backend-plugin-api/alpha');
24
25
  var luxon = require('luxon');
25
- var backendCommon = require('@backstage/backend-common');
26
26
  var jose = require('jose');
27
27
  var uuid = require('uuid');
28
28
  var pluginAuthNode = require('@backstage/plugin-auth-node');
29
29
  var types = require('@backstage/types');
30
+ var backendCommon = require('@backstage/backend-common');
30
31
  var backendAppApi = require('@backstage/backend-app-api');
31
32
  var cookie = require('cookie');
32
33
  var Router = require('express-promise-router');
@@ -66,6 +67,7 @@ var cors__default = /*#__PURE__*/_interopDefaultCompat(cors);
66
67
  var helmet__default = /*#__PURE__*/_interopDefaultCompat(helmet);
67
68
  var morgan__default = /*#__PURE__*/_interopDefaultCompat(morgan);
68
69
  var compression__default = /*#__PURE__*/_interopDefaultCompat(compression);
70
+ var kebabCase__default = /*#__PURE__*/_interopDefaultCompat(kebabCase);
69
71
  var Router__default = /*#__PURE__*/_interopDefaultCompat(Router);
70
72
  var express__default = /*#__PURE__*/_interopDefaultCompat(express);
71
73
  var trimEnd__default = /*#__PURE__*/_interopDefaultCompat(trimEnd);
@@ -536,10 +538,11 @@ function applyCspDirectives(directives) {
536
538
  delete result["form-action"];
537
539
  if (directives) {
538
540
  for (const [key, value] of Object.entries(directives)) {
541
+ const kebabCaseKey = kebabCase__default.default(key);
539
542
  if (value === false) {
540
- delete result[key];
543
+ delete result[kebabCaseKey];
541
544
  } else {
542
- result[key] = value;
545
+ result[kebabCaseKey] = value;
543
546
  }
544
547
  }
545
548
  }
@@ -1564,6 +1567,52 @@ checkForMissingDeps_fn = function(factory, pluginId) {
1564
1567
  };
1565
1568
  let ServiceRegistry = _ServiceRegistry;
1566
1569
 
1570
+ const LOGGER_INTERVAL_MAX = 6e4;
1571
+ function joinIds(ids) {
1572
+ return [...ids].map((id) => `'${id}'`).join(", ");
1573
+ }
1574
+ function createInitializationLogger(pluginIds, rootLogger) {
1575
+ const logger = rootLogger == null ? void 0 : rootLogger.child({ type: "initialization" });
1576
+ const starting = new Set(pluginIds);
1577
+ const started = /* @__PURE__ */ new Set();
1578
+ logger == null ? void 0 : logger.info(`Plugin initialization started: ${joinIds(pluginIds)}`);
1579
+ const getInitStatus = () => {
1580
+ let status = "";
1581
+ if (started.size > 0) {
1582
+ status = `, newly initialized: ${joinIds(started)}`;
1583
+ started.clear();
1584
+ }
1585
+ if (starting.size > 0) {
1586
+ status += `, still initializing: ${joinIds(starting)}`;
1587
+ }
1588
+ return status;
1589
+ };
1590
+ let interval = 1e3;
1591
+ let prevInterval = 0;
1592
+ let timeout;
1593
+ const onTimeout = () => {
1594
+ logger == null ? void 0 : logger.info(`Plugin initialization in progress${getInitStatus()}`);
1595
+ const nextInterval = Math.min(interval + prevInterval, LOGGER_INTERVAL_MAX);
1596
+ prevInterval = interval;
1597
+ interval = nextInterval;
1598
+ timeout = setTimeout(onTimeout, nextInterval);
1599
+ };
1600
+ timeout = setTimeout(onTimeout, interval);
1601
+ return {
1602
+ onPluginStarted(pluginId) {
1603
+ starting.delete(pluginId);
1604
+ started.add(pluginId);
1605
+ },
1606
+ onAllStarted() {
1607
+ logger == null ? void 0 : logger.info(`Plugin initialization complete${getInitStatus()}`);
1608
+ if (timeout) {
1609
+ clearTimeout(timeout);
1610
+ timeout = void 0;
1611
+ }
1612
+ }
1613
+ };
1614
+ }
1615
+
1567
1616
  var __accessCheck$8 = (obj, member, msg) => {
1568
1617
  if (!member.has(obj))
1569
1618
  throw TypeError("Cannot " + msg);
@@ -1768,6 +1817,10 @@ doStart_fn = async function() {
1768
1817
  }
1769
1818
  }
1770
1819
  const allPluginIds = [...pluginInits.keys()];
1820
+ const initLogger = createInitializationLogger(
1821
+ allPluginIds,
1822
+ await __privateGet$6(this, _serviceRegistry).get(backendPluginApi.coreServices.rootLogger, "root")
1823
+ );
1771
1824
  await Promise.all(
1772
1825
  allPluginIds.map(async (pluginId) => {
1773
1826
  await __privateGet$6(this, _serviceRegistry).initializeEagerServicesWithScope(
@@ -1814,12 +1867,14 @@ doStart_fn = async function() {
1814
1867
  );
1815
1868
  });
1816
1869
  }
1870
+ initLogger.onPluginStarted(pluginId);
1817
1871
  const lifecycleService2 = await __privateMethod$5(this, _getPluginLifecycleImpl, getPluginLifecycleImpl_fn).call(this, pluginId);
1818
1872
  await lifecycleService2.startup();
1819
1873
  })
1820
1874
  );
1821
1875
  const lifecycleService = await __privateMethod$5(this, _getRootLifecycleImpl, getRootLifecycleImpl_fn).call(this);
1822
1876
  await lifecycleService.startup();
1877
+ initLogger.onAllStarted();
1823
1878
  if (process.env.NODE_ENV !== "test") {
1824
1879
  const rootLogger = await __privateGet$6(this, _serviceRegistry).get(
1825
1880
  backendPluginApi.coreServices.rootLogger,
@@ -1948,7 +2003,7 @@ function createSpecializedBackend(options) {
1948
2003
  const MIGRATIONS_TABLE = "backstage_backend_public_keys__knex_migrations";
1949
2004
  const TABLE = "backstage_backend_public_keys__keys";
1950
2005
  function applyDatabaseMigrations(knex) {
1951
- const migrationsDir = backendCommon.resolvePackagePath(
2006
+ const migrationsDir = backendPluginApi.resolvePackagePath(
1952
2007
  "@backstage/backend-app-api",
1953
2008
  "migrations"
1954
2009
  );