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

opskins-oauth-v2

v1.1.2

Published

A wrapper package around OPSkin's oAuth API. Supports promises.

Downloads

14

Readme

opskins-oauth-v2

OPSkins-oAuth-v2 is a simple wrapper package around OPSkins oAuth API. Inspired by almatrass's package called opskins-oauth. That package is currently deprecated but the new one supports only PassportJS. This is a rebuilt authentication wrapper package, which supports promises.

Usage

Install the package by typing npm i opskins-oauth-v2 in your project folder.

Setup

const OpskinsAuth = require("opskins-oauth-v2");

const opskins = new OpskinsAuth({
  name: "testing", // Site name displayed to users on logon
  returnUrl: "http://localhost:5000/auth/opskins/authenticate", // Your return route
  apiKey: "2087fcb59f2be98c8a5bbfe245669d", // OPSkins API key
  scopes: "identity_basic trades", // Scopes you want to access
  mobile: true, // Removes login navbar if true
  permanent: true // Maintains permanent access and gives refresh token if true
});

Routes

app.get("/auth/opskins", async (req, res) => {
  const redirectUrl = await opskins.getRedirectUrl();
  return res.redirect(redirectUrl);
});

app.get("/auth/opskins/authenticate", async (req, res) => {
  try {
    const user = await opskins.authenticate(req);

    //...do something with the data
  } catch (error) {
    console.error(error);
  }
});

Methods

getRedirectUrl

Gets the redirect URL to OPSkins.

Parameters

None

Returns

  • Promise (String)

Example

opskins.getRedirectUrl().then(url => {
  //...do something with the url
});

authenticate

Authenticates the user with oAuth.

Parameters

  • request (ExpressJsRequest, Object)

Returns

  • Promise (UserObject)

Example

opskins.authenticate(req).then(user => {
  //...do something with the user
});

getOAuthClient

Gets the oAuth Client information.

Parameters

None.

Returns

  • Promise (ClientObject)

Example

opskins.getOAuthClient().then(client => {
  //...do something with the client
});

Objects

UserObject

Object which holds all the authenticated user's data. The refresh_token key is additional so it's emitted only when permanent is set to true.

Example

{
  id: 1234567,
  id64: "12345678912345678",
  username: "Example Username",
  avatar: "...",
  preferred_currency: 123,
  preferred_lang: "eng",
  balance: 0,
  credits: 0,
  cryptoBalances: 0,
  access_token: "...",
  refresh_token: "...",
}

ClientObject

Object which holds the oAuth client data.

Example

{
  clientId: 1234567,
  clientSecret: "...",
}

License

MIT <3