diff --git a/.changeset/two-wasps-mix.md b/.changeset/two-wasps-mix.md new file mode 100644 index 0000000000..47d8a8a89b --- /dev/null +++ b/.changeset/two-wasps-mix.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs-module-addons-contrib': patch +--- + +Internal refactor for safer handling of possible null value. diff --git a/packages/backend-app-api/src/wiring/ServiceRegistry.ts b/packages/backend-app-api/src/wiring/ServiceRegistry.ts index 90b108206e..c4b9dcb2a3 100644 --- a/packages/backend-app-api/src/wiring/ServiceRegistry.ts +++ b/packages/backend-app-api/src/wiring/ServiceRegistry.ts @@ -22,8 +22,8 @@ import { } from '@backstage/backend-plugin-api'; import { ConflictError, stringifyError } from '@backstage/errors'; // Direct internal import to avoid duplication -// eslint-disable-next-line @backstage/no-forbidden-package-imports -import { InternalServiceFactory } from '@backstage/backend-plugin-api/src/services/system/types'; +// eslint-disable-next-line @backstage/no-relative-monorepo-imports +import { InternalServiceFactory } from '../../../backend-plugin-api/src/services/system/types'; import { DependencyGraph } from '../lib/DependencyGraph'; /** * Keep in sync with `@backstage/backend-plugin-api/src/services/system/types.ts` diff --git a/packages/backend-defaults/src/entrypoints/auth/JwksClient.ts b/packages/backend-defaults/src/entrypoints/auth/JwksClient.ts index 44f0082424..f956ceb70a 100644 --- a/packages/backend-defaults/src/entrypoints/auth/JwksClient.ts +++ b/packages/backend-defaults/src/entrypoints/auth/JwksClient.ts @@ -22,7 +22,7 @@ import { FlattenedJWSInput, JWSHeaderParameters, } from 'jose'; -import { GetKeyFunction } from 'jose/dist/types/types'; +import { GetKeyFunction } from 'jose'; const CLOCK_MARGIN_S = 10; diff --git a/packages/backend-defaults/src/entrypoints/auth/plugin/keys/StaticConfigPluginKeySource.ts b/packages/backend-defaults/src/entrypoints/auth/plugin/keys/StaticConfigPluginKeySource.ts index 658a88a368..eb863a807a 100644 --- a/packages/backend-defaults/src/entrypoints/auth/plugin/keys/StaticConfigPluginKeySource.ts +++ b/packages/backend-defaults/src/entrypoints/auth/plugin/keys/StaticConfigPluginKeySource.ts @@ -18,7 +18,7 @@ import { Config } from '@backstage/config'; import { HumanDuration, durationToMilliseconds } from '@backstage/types'; import { promises as fs } from 'fs'; import { JWK, exportJWK, importPKCS8, importSPKI } from 'jose'; -import { KeyLike } from 'jose/dist/types/types'; +import { KeyLike } from 'jose'; import { KeyPayload } from './types'; import { PluginKeySource } from './types'; diff --git a/packages/backend-defaults/src/entrypoints/rootHttpRouter/http/readHelmetOptions.ts b/packages/backend-defaults/src/entrypoints/rootHttpRouter/http/readHelmetOptions.ts index 510fdd9586..fc1fc59bcb 100644 --- a/packages/backend-defaults/src/entrypoints/rootHttpRouter/http/readHelmetOptions.ts +++ b/packages/backend-defaults/src/entrypoints/rootHttpRouter/http/readHelmetOptions.ts @@ -17,7 +17,6 @@ import { Config } from '@backstage/config'; import helmet from 'helmet'; import { HelmetOptions } from 'helmet'; -import { ContentSecurityPolicyOptions } from 'helmet/dist/types/middlewares/content-security-policy'; import kebabCase from 'lodash/kebabCase'; /** @@ -81,10 +80,15 @@ function readCspDirectives(config?: Config): CspDirectives { return result; } +type ContentSecurityPolicyDirectives = Exclude< + HelmetOptions['contentSecurityPolicy'], + boolean | undefined +>['directives']; + export function applyCspDirectives( directives: CspDirectives, -): ContentSecurityPolicyOptions['directives'] { - const result: ContentSecurityPolicyOptions['directives'] = +): ContentSecurityPolicyDirectives { + const result: ContentSecurityPolicyDirectives = helmet.contentSecurityPolicy.getDefaultDirectives(); // TODO(Rugvip): We currently use non-precompiled AJV for validation in the frontend, which uses eval. diff --git a/packages/backend-test-utils/src/next/wiring/TestBackend.ts b/packages/backend-test-utils/src/next/wiring/TestBackend.ts index 42b46f4de7..4471f6ed24 100644 --- a/packages/backend-test-utils/src/next/wiring/TestBackend.ts +++ b/packages/backend-test-utils/src/next/wiring/TestBackend.ts @@ -27,11 +27,11 @@ import { mockServices } from '../services'; import { ConfigReader } from '@backstage/config'; import express from 'express'; // Direct internal import to avoid duplication -// eslint-disable-next-line @backstage/no-forbidden-package-imports +// eslint-disable-next-line @backstage/no-relative-monorepo-imports import { InternalBackendFeature, InternalBackendRegistrations, -} from '@backstage/backend-plugin-api/src/wiring/types'; +} from '../../../../backend-plugin-api/src/wiring/types'; import { DefaultRootHttpRouter, ExtendedHttpServer, diff --git a/plugins/auth-backend/src/identity/StaticKeyStore.ts b/plugins/auth-backend/src/identity/StaticKeyStore.ts index 13b9faf771..f7274d4b83 100644 --- a/plugins/auth-backend/src/identity/StaticKeyStore.ts +++ b/plugins/auth-backend/src/identity/StaticKeyStore.ts @@ -15,7 +15,7 @@ */ import { AnyJWK, KeyStore, StoredKey } from './types'; import { exportJWK, importPKCS8, importSPKI, JWK } from 'jose'; -import { KeyLike } from 'jose/dist/types/types'; +import { KeyLike } from 'jose'; import { promises as fs } from 'fs'; import { Config } from '@backstage/config'; diff --git a/plugins/auth-node/src/identity/DefaultIdentityClient.ts b/plugins/auth-node/src/identity/DefaultIdentityClient.ts index 1095609dec..75b81cb0cd 100644 --- a/plugins/auth-node/src/identity/DefaultIdentityClient.ts +++ b/plugins/auth-node/src/identity/DefaultIdentityClient.ts @@ -24,7 +24,7 @@ import { JWSHeaderParameters, jwtVerify, } from 'jose'; -import { GetKeyFunction } from 'jose/dist/types/types'; +import { GetKeyFunction } from 'jose'; import { getBearerTokenFromAuthorizationHeader } from './getBearerTokenFromAuthorizationHeader'; import { IdentityApi, IdentityApiGetIdentityRequest } from './IdentityApi'; import { BackstageIdentityResponse } from '../types'; diff --git a/plugins/techdocs-module-addons-contrib/src/LigthBox/LightBox.tsx b/plugins/techdocs-module-addons-contrib/src/LigthBox/LightBox.tsx index 38269e6245..47409f47c7 100644 --- a/plugins/techdocs-module-addons-contrib/src/LigthBox/LightBox.tsx +++ b/plugins/techdocs-module-addons-contrib/src/LigthBox/LightBox.tsx @@ -28,7 +28,7 @@ export const LightBoxAddon = () => { useEffect(() => { let dataSourceImages: DataSource | null = null; - let lightbox = new PhotoSwipeLightbox({ + let lightbox: PhotoSwipeLightbox | null = new PhotoSwipeLightbox({ pswpModule: PhotoSwipe, initialZoomLevel: 1, secondaryZoomLevel: (zoomLevelObject: ZoomLevel) => { @@ -71,14 +71,14 @@ export const LightBoxAddon = () => { }; }); } - lightbox.loadAndOpen(index, dataSourceImages); + lightbox?.loadAndOpen(index, dataSourceImages); return false; }; }); lightbox.init(); return () => { - lightbox.destroy(); + lightbox?.destroy(); lightbox = null; }; }, [images]);