I have a master application that accepts plugin modules, except for some functionality (authentication) where for some reason it seems hell-bent to prevent plugins from adding authentication methods. Despite that, I still need to do exactly that - add a new authentication method, but via a plugin.
The master application has a typescript module that exports an Authenticator
class,
export class Authenticator {
constructor(arg) { dostuff(arg); }
}
I need to somehow intercept the constructor argument and store it in my plugin. The Authenticator
class is instantiated in private code, but fortunately, after my plugin is initialized - so I get a chance to run some code; is there any way to dynamically modify the Authenticator
class object (i.e. the class itself) so that I may capture the argument, when it is actually instantiated? Note that I can't use a decorator (I'd need to modify the main app), and I can't instantiate a proxy instead of the Authenticator (again, I would need to modify the main app in order to do so).
I've tried modifying Authenticator.constructor
or Authenticator.prototype.constructor
but neither works apparently. Is there any other way?