export function updateConfigContext()

in src/ConfigContext.ts [126:182]


export function updateConfigContext(newContext: Partial<ConfigContext>): void {
  if (!newContext) {
    return;
  }

  if (!validateEndpoint(newContext.ARM_ENDPOINT, configContext.allowedArmEndpoints || defaultAllowedArmEndpoints)) {
    delete newContext.ARM_ENDPOINT;
  }

  if (!validateEndpoint(newContext.AAD_ENDPOINT, allowedAadEndpoints)) {
    delete newContext.AAD_ENDPOINT;
  }

  if (!validateEndpoint(newContext.EMULATOR_ENDPOINT, allowedEmulatorEndpoints)) {
    delete newContext.EMULATOR_ENDPOINT;
  }

  if (!validateEndpoint(newContext.GRAPH_ENDPOINT, allowedGraphEndpoints)) {
    delete newContext.GRAPH_ENDPOINT;
  }

  if (!validateEndpoint(newContext.ARCADIA_ENDPOINT, allowedArcadiaEndpoints)) {
    delete newContext.ARCADIA_ENDPOINT;
  }

  if (
    !validateEndpoint(
      newContext.MONGO_PROXY_ENDPOINT,
      configContext.allowedMongoProxyEndpoints || defaultAllowedMongoProxyEndpoints,
    )
  ) {
    delete newContext.MONGO_PROXY_ENDPOINT;
  }

  if (
    !validateEndpoint(
      newContext.CASSANDRA_PROXY_ENDPOINT,
      configContext.allowedCassandraProxyEndpoints || defaultAllowedCassandraProxyEndpoints,
    )
  ) {
    delete newContext.CASSANDRA_PROXY_ENDPOINT;
  }

  if (!validateEndpoint(newContext.JUNO_ENDPOINT, allowedJunoOrigins)) {
    delete newContext.JUNO_ENDPOINT;
  }

  if (!validateEndpoint(newContext.hostedExplorerURL, allowedHostedExplorerEndpoints)) {
    delete newContext.hostedExplorerURL;
  }

  if (!validateEndpoint(newContext.msalRedirectURI, allowedMsalRedirectEndpoints)) {
    delete newContext.msalRedirectURI;
  }

  Object.assign(configContext, newContext);
}