npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@goodhum/gh-angular-auth

v0.0.9

Published

Authentication module for Angular4+

Downloads

27

Readme

gh-angular-auth

gh-angular-auth is a module you can add to your Angular4+ app in order to quickly setup Auth0 and Firebase authentication support.

Install

npm install --save @goodhum/gh-angular-auth

Pre Setup

Firebase

Login to your firebase console and enable the sign-in method for the providers you want to use from Authentication Menu on left side.

Auth0 (Only if you want to get user meta_data)

 1. Login to auth 0.
 2. Click on Rules menu from left.
 3. Create a rule.
 4. Select empty rule.
 5. Give a name 'attach appmetadata'
 6. Update the function with the following settings 
         function (user, context, callback) {
           var namespace = 'https://<YOUR-DOMAIN>/';
           context.idToken[namespace + 'app_metadata'] = user.app_metadata; 
           
           callback(null, user, context);
         }
 7. Save the rule

Configuration

export interface FirebaseConfig {
    apiKey: string;
    authDomain: string;
    databaseURL: string;
    projectId: string;
    storageBucket: string;
    messagingSenderId: string;
}

export interface Auth0Config {
    domain: string;
    client_id: string;
    scope?: string;
    realm?: string;
    grant_type?: string;
}

export abstract class ProvidersConfig {
    firebase?: FirebaseConfig;
    auth0?: Auth0Config;
};

Methods

Auth Service

| Methods | Notes | |----------------------------------------|-------------------------------------------------------------| | provider(provider: string): Provider | Get the provider you want to use. 'auth0' or 'firebase'. | | login(user: User): Observable | Login with provider. | | logout(): void | Logout of the provider. | | signUp(): void | SignUp with email and password to the desired provider. | | resetPassword(): void | Request a reset password link to email for desired provider.|

User Service

| Methods | Notes | |----------------------------------------|-------------------------------------------------------------| | getLoggedInProvider(): string | Get providers that have been logged in with. | | getUserProfile(): Object | Get user profile. | | getUserProfileFromToken: Object | Get user profile from jwt token. | | getToken(): string | Get user JWT token. | | canActivate(): Observable | Get can activate. | | isAuthenticated(): boolean | Get if user is authenticated. |

Initialization

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { GhAuthModule, ProvidersConfig } from '@goodhum/gh-angular-auth';

import { AppComponent } from './app.component';


const config: ProvidersConfig = {
     auth0: {
        YOUR AUTH0 CONFIGURATION 
     },
     firebase: {
        YOUR FIREBASE CONFIGURATION
     }
     redirectUrl: URL to redirect on CanActivate false
};


@NgModule({
    declarations: [
        AppComponent
    ],
    imports: [
        BrowserModule,
        GhAuthModule.forRoot(config)
    ],
    providers: [],
    bootstrap: [AppComponent]
})
export class AppModule {}

Examples

import { Component, OnInit } from '@angular/core';
import { AuthService, User, UserService } from '@goodhum/gh-angular-auth';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
    authProvider: any;

    constructor(public auth: AuthService,
                private userservice: UserService) { }


    ngOnInit() {
        this.authProvider = this.auth.provider('firebase');
    }

    login(provider, username, password) {
        const user: User = { username: username, password: password };
        
        this.authProvider.login(user).subscribe(res => {
            console.log(res);
        }, error => console.log('Error Login', error));
    }

    logout() {
        this.authProvider.logout().subscribe(res => console.log(res));
    }
}

License

MIT