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

sso-client

v2.0.1

Published

Client javascript de consumo do SSO Server

Readme

SSO Client

Biblioteca javascript de consumo do SSO Server.

Para utilizar a biblioteca de SSO Client basta instanciar o objeto de SSO no boostrap da sua aplicação.

Por exemplo:

1. No boostrap da sua aplicação

import configuration from 'app.config.js'
window.SSO = new Sso(configuration.sso);

Criar um arquivo chamado app.config.js com as configurações do sso, conforme trecho abaixo.

app.config.js (Alterar os atributos cookieDomain e gatewayEndpointLogin e adicionar o GUID e SECRET da aplicação atual para os respectivos valores conforme ambiente)

export default {
  sso: {
    authentication: {
      consts: {
        token: 'HB-AUTH-TOKEN',
        // cookieDomain: 'ontimeambev.com.br',
        cookieDomain: 'localhost',
      },
      front: {
        //a cada 30 minutos
        timeToRenewToken: (1000 * 60 * 30),
        //a cada 43 minutos, foi multiplicado por 3.33 para não dar conflito com o tempo de renew
        inactiveTimeToLogout: (1000 * 60 * 13 * 3.33),
        // gatewayEndpointLogin: 'https://ontimeambev.com.br/app/login',
        gatewayEndpointLogin: 'http://localhost:3003/app/login',
      },
      api: {
        timeout: 10000,
        server: 'https://sso.ontimeambev.com.br',
        ssoEndpoint: 'api/authsso/login',
        basicEndpoint: 'api/authbasic/login',
        claimsEndpoint: 'api/token/getClaims',
        renewEndpoint: 'api/token/Renew',
        consumer: {
          guid: '',
          secret: ''
        }
      }
    }
  }
}

Para enviar o token para o seu backend, no interceptor da sua biblioteca de requisições, adicionar o token nos headers da requisição, exemplo do axios:

2. Axios

const storedToken = SSO.getTokenJwt()

if (storedToken != ""){
  config.headers = config.headers || {};
  config.headers["Content-type"] = "application/json"
  config.headers[SSO.settings.authentication.consts.token] = storedToken
}

3. Verificação de usuário autenticado (React)

app.js

async componentWillMount () {
    const token = await SSO.getTokenJwt()
    
    if (!token || Object.keys(token).length == 0) {
      SSO.logoutAndRedirectLoginWithReturnUrl()
    }
}

Funções disponíveis no SSO Client:

Limpa dos cookies de autenticação

clearCookies(returnURL) : void

Retorna um objeto com as claims do usuário

getClaimsAsync() : Promise

Retorna a string do token de autenticação

getTokenJwt(returnURL) : string

Retorna o objeto de autenticação

getTokenObject(returnURL) : object 

Retorna o nome do usuário

getUserName(returnURL) : string 

Retorna as aplicações que o usuário tem acesso

getUserApps(returnURL) : array

Login automático por NTLM (Windows Autentication).

loginAsync() : Promise 

Login com as credenciais (usuario e senha)

loginWithCredentialsAsync() : Promise

Faz o logout, limpa os dados de autenticação

logout(callback) : void

Faz o logout e redireciona para a tela de login, possibilitando passar uma url de retorno, caso contrario ele pega a URL de origem do logout para redirecionar devoltar

logoutAndRedirectLoginWithReturnUrl(returnURL) : void

Faz a requisição de uma renovação de token

renewTokenAsync() : Promise

Seta um token no cookie

setToken(returnURL) : void