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

oauth2-gcts

v1.0.3

Published

OAuth2 Client for JavaScript projects written in TypeScript

Downloads

11

Readme

OAuth2 Client

OAuth2 Client for JavaScript projects written in TypeScript

Installation

npm install oauth2-gcts

Usage

Config

import { OAuth2Client, OAuth2ClientConfig } from 'oauth2-gcts'

const host = "http://localhost:3030/api/v1/oauth2"

const config : OAuth2ClientConfig = {
    apiKey : "some_key", 
    apiSecret : "some_secret",
    tokenURL: `${host}/token`,
    registerURL : `${host}/register`,
    verifyAccountURL : `${host}/verify_account`,
    resetPasswordURL : `${host}/reset_password`,
    validateTokenURL : `${host}/validate`
}

const client = new OAuth2Client(config)

Register a new user

client.register(new CoreUser(email, password, "Helmer", "Barcos"))
    .then((res) => {
        if (res.wasSuccessful()) {
            console.log("user_id = " + res.getID())
        } else {
            console.error(res.getErrorMessage())
        }
    })
    .catch(err => console.error(err.error || err.message))

Verify user account

client.verifyAccount(token)
    .then((res) => {
        if (res.wasSuccessful()) {
            console.log("Account verified successfully")
        } else {
            console.error(res.getErrorMessage())
        }
    })
    .catch(err => console.error(err.error || err.message))

Access with client credentials

client.login({ email, password })
    .then((res) => {
        if (res.wasSuccessful()) {
            console.log(res.getTokens())
        } else {
            throw new Error("Unable to login " + res.getErrorMessage())
        }
    })
    .catch(err => console.error(err.error || err.message))

Refresh user session

client.login({ email, password })
    .then((res) => {
        if (!res.wasSuccessful()) {
            throw new Error("Unable to login " + res.getErrorMessage())
        }
    })
    .then(() => client.refreshAccess()) // .then(() => client.refreshAccess("some_token"))
    .then((res) => {
        if (res.wasSuccessful()) {
            console.log(res.getTokens())
        } else {
            console.error(res.getErrorMessage())
        }
    })
    .catch(err => console.error(err.error || err.message))

Reset user pwd

client.startResetPassword(email)
    .then((res) => {
        if (res.wasSuccessful()) {
            console.log("Reset password Email sent successfully")
        } else {
            console.error(res.getErrorMessage())
        }
    })
    .catch(err => console.error(err.error || err.message))

// verification_token sent via email
client.doResetPassword(email, { old_password : password, new_password : newPwd, verification_token : pwdToken })
    .then((res) => {
        if (res.wasSuccessful()) {
            console.log("pwd changed successfully")
        } else {
            console.error(res.getErrorMessage())
        }
        password = newPwd
    })
    .catch(err => console.error(err.error || err.message))

Validate token

client.login({ email, password })
    .then((res) => {
        if (!res.wasSuccessful()) {
            throw new Error("Unable to login " + res.getErrorMessage())
        }
    })
    .then(() => myTimeout())
    .then(() => client.validateToken()) // .then(() => client.validateToken("some_access_token"))
    .then((res) => {
        if (res.wasSuccessful()) {
            console.log("token validated successfully")
            console.log("isTokenValid = ", res.isTokenValid())
        } else {
            console.error(res.getErrorMessage())
        }
    })
    .catch(err => console.error(err.error || err.message))

Publish

npm run build && npm publish

License

MIT