Skip to content

Commit

Permalink
Refactor .snyk to ignore hard-coded appKey in app.config.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Noggling committed Oct 16, 2024
1 parent d5abfc2 commit 06457dd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
17 changes: 8 additions & 9 deletions client/apps/legacyAppLoader/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ interface Client {
export const configure: AppModuleInitiator<
[NavigationModule],
Fusion<unknown>,
{ config: { environment: { endpoints: { client: Client; portal: Client } } } }
> = (configurator, env) => {
configurator.configureHttpClient('portal-client', env.env.config?.environment.endpoints.client);
configurator.configureHttpClient('portal', env.env.config?.environment.endpoints.portal);
{ config: { environment: { endpoints: { client: Client; portal: Client; fusion: Client } } } }
> = (configurator, { env, fusion }) => {
configurator.configureHttpClient('portal-client', env.config?.environment.endpoints.client);
configurator.configureHttpClient('portal', env.config?.environment.endpoints.portal);

window['clientBaseUri'] = env.env.config?.environment.endpoints.client.baseUri;
window['clientBaseUri'] = env.config?.environment.endpoints.client.baseUri;
// configurator.logger.level = 4;
configurator.configureHttpClient('app', {
baseUri: new URL('/apps-proxy/', location.origin).href,
defaultScopes: ['5a842df8-3238-415d-b168-9f16a6a6031b/.default'],
defaultScopes: env.config?.environment.endpoints.fusion.defaultScopes,
});

enableAppModule(configurator);
Expand All @@ -41,9 +41,8 @@ export const configure: AppModuleInitiator<
if (nav.action !== 'PUSH') return;

if (
nav.location.pathname
.split('/')
.filter((path) => path === env.fusion.modules.context.currentContext?.id).length > 1
nav.location.pathname.split('/').filter((path) => path === fusion.modules.context.currentContext?.id)
.length > 1
) {
instance.navigation.navigator.go(-1);
}
Expand Down
4 changes: 3 additions & 1 deletion client/packages/core/src/app/hooks/use-app-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useAppModule } from './use-app-module';
import { useLegacyAppLoader } from './use-legacy-app-loader';
import { createAppElement } from '../utils/app-element';
import { appRender } from '../render';
import { getLegacyClientConfig, getFusionLegacyEnvIdentifier } from '../utils';
import { getLegacyClientConfig, getFusionLegacyEnvIdentifier, getLegacyFusionConfig } from '../utils';

import { AppConfig } from '@equinor/fusion-framework-app';
import { ConfigEnvironment } from '@equinor/fusion-framework-module-app';
Expand Down Expand Up @@ -57,6 +57,7 @@ export const useAppLoader = (appKey: string) => {
loadingText: 'Loading',
endpoints: {
client: getLegacyClientConfig(),
fusion: getLegacyFusionConfig(),
},
},
} as AppConfig<
Expand All @@ -66,6 +67,7 @@ export const useAppLoader = (appKey: string) => {
loadingText: string;
endpoints: {
client: Client;
fusion: Client;
};
}
>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ export const getLegacyClientConfig = (): Client => ({
baseUri: window._config_.portalClient.client.baseUri,
defaultScopes: window._config_.portalClient.client.defaultScopes,
});
export const getLegacyFusionConfig = (): Client => ({
baseUri: window._config_.serviceDiscovery.client.baseUri,
defaultScopes: window._config_.serviceDiscovery.client.defaultScopes,
});

export const getFusionLegacyEnvIdentifier = (): string => {
return window._config_.fusionLegacyEnvIdentifier.toUpperCase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export function createPortalFramework(portalConfig: PortalConfig) {

config.configureHttpClient('app', {
baseUri: new URL('/apps-proxy/', location.origin).href,
defaultScopes: ['5a842df8-3238-415d-b168-9f16a6a6031b/.default'],
defaultScopes: portalConfig.serviceDiscovery.client.defaultScopes,
});

config.configureMsal(portalConfig.msal.client, portalConfig.msal.options);
Expand Down

0 comments on commit 06457dd

Please sign in to comment.