module Sfx { function bootstrap ( ) { angular . element ( document ) . ready ( ( ) => { angular . bootstrap ( document , [ Constants . sfxAppName ] , { strictDi : true } ) ; } ) ; } ( function ( ) { if ( StandaloneIntegration . isStandalone ( ) ) { angular . module ( "authenticationBootstrap" , [ "AdalAngular" ] ) . constant ( "authenticationData" , new AadMetadata ( null ) ) ; return bootstrap ( ) ; } let match = /[&?#](error=.*)/i . exec ( window . location . href ) ; if ( match && match [ 1 ] ) { console . log ( "Error post back url: " + window . location . href ) ; window . top . location . href = "/Explorer/error.html?" + match [ 1 ] ; return ; } let initInjector = angular . injector ( [ "ng" ] ) ; let $http = initInjector . get ( "$http" ) ; $http . get ( StandaloneIntegration . clusterUrl + AuthenticationBootstrapConstants . GetAadMetadataUriPart ) . then ( ( response ) => { if ( response . status >= 300 ) { return initInjector . get ( "$q" ) . reject ( ) ; } const data = < IRawAadMetadata > response . data ; let authBootstrap = angular . module ( "authenticationBootstrap" , [ "AdalAngular" ] ) ; authBootstrap . constant ( "authenticationData" , new AadMetadata ( data ) ) ; authBootstrap . config ( [ "$httpProvider" , "adalAuthenticationServiceProvider" , "authenticationData" , function ( $httpProvider , adalAuthenticationServiceProvider , authenticationData ) { if ( authenticationData . metadata && authenticationData . isAadAuthType && authenticationData . metadata . tenant !== "" ) { let adalData = authenticationData . metadata ; let aadConfigOptions = { clientId : adalData . cluster , tenant : adalData . tenant , cacheLocation : AuthenticationBootstrapConstants . AdalCacheType } ; if ( StandaloneIntegration . clusterUrl !== "" ) { aadConfigOptions . redirectUri = StandaloneIntegration . clusterUrl + "/Explorer/index.html" ; aadConfigOptions . postLogoutRedirectUri = StandaloneIntegration . clusterUrl + "/Explorer/index.html" ; } if ( adalData . login ) { aadConfigOptions . instance = StringUtils . EnsureEndsWith ( adalData . login , "/" ) ; } else if ( adalData . authority ) { let parser = document . createElement ( "a" ) ; parser . href = adalData . authority ; aadConfigOptions . instance = parser . protocol + "//" + parser . host + "/" ; } adalAuthenticationServiceProvider . init ( aadConfigOptions , $httpProvider ) ; } } ] ) ; } ) . catch ( ( ) => { let authBootstrap = angular . module ( "authenticationBootstrap" , [ "AdalAngular" ] ) ; authBootstrap . constant ( "authenticationData" , new AadMetadata ( null ) ) ; } ) . finally ( ( ) => bootstrap ( ) ) ; } ) ( ) ; }