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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng-jwt-token

v0.0.4

Published

FEATURES OF ng-jwt-token:

Downloads

35

Readme

NgJwtToken

FEATURES OF ng-jwt-token:

  1. On login stores 'access-token' (library's memory) and 'refresh-token' (local storage).
  2. On browser refresh identifies user to be in login state.
  3. Returns tokens.
  4. Validates the token structure.
  5. Decodes the tokens.
  6. Returns token's payload (or) specific value for a key/keys in the token's payload.
  7. Tracks validity (or) expiry time of the token.
  8. Set token to header with various configuration options.
  9. Clears data on user log out.

JWT service methods and functionalities:

  1. On login success or refreshing browser:

    Call: doLoginUser(username?: string, tokens?: any): Observable

    Parameters: On login pass username and tokens of format [Access-Token: 'value', Refresh-Token: 'value]; On browser refresh need not pass any parameters, library will check for refresh token in local storage and return the login state of user.

    Functionality: Store tokens and user-login details. Returns the login-state of user. Returns true if tokens are stored and valid otherwise false.

  2. On logout:

    Call: doLogoutUser()

    Functionality: Clears tokens and user-login details,

  3. To get token's full payload (or) a set of values for the keys in the payload

    Call : getTokenPayloadValueFor(tokenType: string, key?: string)

    Parameters: tokenType - 'accessToken' (or) 'refreshToken'

            key (optional) - ['key1'] (or) ['key1', 'key2', 'key3']
    
                             If a key is passed respective values are returned in an object format {key1: value1} 
    
                             If key is not passed, which is optional, full payload from token is returned.

    Functionality: Returns entire payload from token (or) values for specific keys in token payload.

  4. To check token's validity (or) expiry status

    Call: isTokenExpired(tokenType: string): Observable

    Parameters: tokenType - 'accessToken' (or) 'refreshToken'.

    Functionality: Checks if token is expired with time difference early of 2 mins for access-token and 5 mins for refresh-token.

  5. Before making an API call, attach token to the request with customized configOptions

    Call: addTokenToRequest(request: HttpRequest, configOptions?: any)

    Parameter - configOptions is of type object - {}

             @configOptions keys & values; headerName - header name to be attached in request payload,
    
                                           authScheme - authentication scheme,
    
                                           excludeURL - URL's to which headers need not be set.
    
                                           (Incase of any initial requests you don't want to send tokens)
    
             @configOptions default keys & values; headerName - Access-Token
    
                                           authScheme - '' (empty)
    
                                           excludeURL - no default

    Functionality: Attaches and returns the request by attaching an access token to the header of the request.

                Call it just before making an API call to the server.

This is my first library. Incase of any queries, please write to [email protected]. Will be happy to help :)