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 🙏

© 2026 – Pkg Stats / Ryan Hefner

mac-authorization

v1.0.12

Published

This is the authorization implementation with Passport oAuth2. Work with SSO.

Readme

MaC - Authorization

This is the authorization implementation with Passport oAuth2. Work with SSO.

Table of Contents

Required Software

npm (tag) npm (tag)

1.1 Node Installation

For node installation go to

npm (tag)

Download the current version which are the one we use.

Follow the steps from this guides bellow to install node.

npm (tag) npm (tag) npm (tag)

1.2 NestJs Installation

The Installation of NestJs is really simple. After install NodeJs you only need run the follow command in your terminal.

$ npm install -g @nestjs/cli

After the installation finish check if your system recognize nest.

$ nest --version

Should output something like this

6.11.3

Now that all required software are installed lets move on into the git clone and git submodule.

Git

First you will need to install git into your system if you don't know how go to guide bellow and you have how to install in 3 major OS.

npm (tag)

After install git into your system you will need to clone the repo to your system. Follow the next steps for success.

With http

$ git clone http://10.172.5.51/mac/backend-folder/backend.git backend

Will ask you to put your credentials. username first and password after. this credentials are the same you use to login into gitlab.


With SSH

$ git clone [email protected]:mac/backend-folder/backend.git backend

This one will not ask for nothing. If throw error just check your profile permissions.


Fork Project

http://10.172.5.51/mac/backend-folder/microservices/authorization/-/forks/new

Access to this url to fork the project and add your namespace.

Configuration

You need to follow some steps before start using this microservice.

3.1 Environment files

The project have 2 environment files, development and production, each one with different configurations. development.env file has all dev endpoints and localhost endpoints. If you wanna chane any variable or endpoint for local test use this file, otherwise use production or create one for other environment.

3.1.1 Environment Variables

CRYPTO_KEY = <JWT KEY>
SSO_AUTH_SCOPE = <SCOPE>
SSO_CLIENT_ID = <CLIENT ID>
SSO_CLIENT_SECRET = <CLIENT SECRET>
SSO_CALLBACK_URL = <URL FOR YOUR APP ENDPOINT http://www.example.com/oauth/token>
SSO_LOGIN_URI = <URL FOR YOUR APP LOGIN ENDPOINT http://www.example.com/oauth/startAuth>
SSO_LOGOUT_URI = <URL FOR YOUR FRONT END ENDPOINT http://www.examplefrontend.com>
SSO_REDIRECT = <URL FOR YOUR FRONT END LOGIC PAGE http://www.examplefrontend.com/auth/login>

To run the microservice with development environment you need run the follow command.

cross-env NODE_ENV=development && nest start --watch

or use the pre-configured script

npm run start:dev

To run the microservice with production environment you need run the follow command.

cross-env NODE_ENV=production && node dist/main

or use the pre-configured script

npm run start:prod

3.2 Set environments

To add new environment files into the project, add a new file in environment folder with like {name}.env where name is the environment name and env is the file extension, do not change or use other extension.

If for some reason the microservice don't start up your new environment go to config folder and open config.module file.

Add the new environment name on this line.

useValue: new ConfigService(`src/environments/${process.env.NODE_ENV || 'development' || 'production' || 'your_env_name'}.env`)

EndPoints

Below are listed all endpoints to this service. Some are not for external use, they are only for sso connect with our application.

4.1 External Endpoints

The external endpoints are the only endpoints you should use with your client. Follow the list.

Angular implementation example

First you need to call the login service to get the server endpoint to start authentication

Component

this.service.login().subscribe(value =>{window.open(value.url, '_self')});

Service

login(): Observable<any> {
    return this.http.get<any>(endpointurl/oauth/login);
}

You will be redirect to SSO authentication. After successful login you will be redirect to the next endpoint which should have your login for example:

Logic Componet

this.service.verifyToken(token).pipe(
    switchMap(value => {
        if (value) {
            return this.service.getUserInfo(token);
        }  
}))
.subscribe(value => {
    if (value) {
        Storage.setLocalMemory('userinfo', value.jwt);    
    }
});

At this point you should have the cookie with access token injected.

This logic first verify token if it is valid, if not we dont go get userInfo. You can skip your verify token and go into getUserInfo since both validate tokens.

To implement logout use the same login logic with window.open.


Powered by