Firing Events from Non-Aura Code
You can fire Aura events from JavaScript code outside an Aura app. For example, your Aura
app might need to call out to some non-Aura code, and then have that code communicate back to
your Aura app once it's done.
For example, you could call external code that needs to log into another system and return some data to your Aura app by firing an Aura event. Let's call this event mynamespace:externalEvent. The external code fires this event when it’s ready to communicate with an Aura app.
var myExternalEvent;
if(window.$A &&
(myExternalEvent = window.$A.get("e.mynamespace:externalEvent"))) {
myExternalEvent.setParams({isOauthed:true});
myExternalEvent.fire();
}