Replacing/Extending Authentication class in AuthService

I have a project using aurelia-auth plugin. I would like to extend parts of the Authentication class so it can handle a more complex flow. All of my attempts to tell the DI system to use the CustomAuth class in its place are failing though. In particular, it seems Container.instance.registerSingleton doesn’t work how I expect from what the docs say:


import {Container, inject} from 'aurelia-framework';
import {Authentication} from 'aurelia-auth';

export class CustomAuth extends Authentication {
        console.log('CustomAuth created')
Container.instance.registerSingleton(Authentication, CustomAuth);

export class CustomAuthService extends AuthService {


import {inject} from 'aurelia-framework';
import {AuthorizeStep, FetchConfig} from 'aurelia-auth';
import {CustomAuthService} from './myauth';

inject(CustomAuthService, FetchConfig);
export class App {
    constructor(auth, fetchConfig){
        this.auth = auth
        this.fetchConfig = fetchConfig
    activate() {
    configureRouter(config, router) {
        config.addPipelineStep('authorize',  AuthorizeStep);

error I’m getting:
Error: key/value cannot be null or undefined. Are you trying to inject/register something that doesn't exist with DI?

Why does it thinks the key or value is missing?

hmmm… so it seems that the registerSingleton method takes a function or Instance as the second argument not the class. Is there a way to do what I want with a Resolver?

Something even more fundamental is going on and I’m not seeing what. Can’t event extend from the classes in aurelia-auth with out errors for getting prototype of undefined.

Ultimately I just trying to get it to work with Firebase Authentication so I don’t have to rewrite a lot of code that uses AuthService and events published by it.

Has anyone else out there tried to extend aurelia-auth or figured out how to shoe-horn firebase/auth into it?

This looks correct, but shouldn’t you do the same for your CustomAuthService, like:


Maybe? Don’t know because aurelia-auth doesn’t work with extend for some reason. Think I’ll just fork the project to make my changes. If I need to extend another plugin’s classes I’ll give the Container api another try.