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

@thynclabs/universal-auth

v1.0.2

Published

Universal Auth is a comprehensive authentication package that enables seamless login integration with GitHub, and more. Simplify your user authentication process with a unified, easy-to-use interface.

Downloads

5

Readme

Universal Auth Package

Universal Auth is a TypeScript package that provides OAuth authentication integration for GitHub. It aims to simplify the process of implementing OAuth authentication in TypeScript projects.

Features

  • GitHub Authentication: Authenticate users using GitHub OAuth.
  • Singleton Pattern: Uses a singleton pattern to ensure a single instance across the application.

Installation

You can install the package via npm (or yarn):

npm install @thynclabs/universal-auth
# or
yarn add @thynclabs/universal-auth

Usage

Initialize GitHub Authentication

To use GitHub OAuth authentication, import the GitHubAuth class from universal-auth:

import { GitHubAuth } from '@thynclabs/universal-auth';

const clientId = 'your-github-client-id';
const clientSecret = 'your-github-client-secret';
const redirectUri = 'http://localhost/callback'; // Replace with your actual redirect URI

const githubAuth = GitHubAuth.getInstance(clientId, clientSecret, redirectUri);

// Get authorization URL
const authorizationUrl = githubAuth.getAuthorizationUrl();
console.log('Authorization URL:', authorizationUrl);

// Redirect users to authorizationUrl to initiate GitHub OAuth flow

Handle Callback

After the user authorizes your application, GitHub will redirect them back to your redirectUri with a code parameter. Use this code to fetch the access token:

// Assuming 'code' is obtained from query parameters
const code = 'code-from-github'; // Replace with actual code

// Get access token
const accessToken = await githubAuth.getAccessToken(code);
console.log('Access Token:', accessToken);

// Use the access token to fetch user information
const userInfo = await githubAuth.getUserInfo(accessToken);
console.log('User Info:', userInfo);

Configuration

GitHub Configuration

You need to register your application on GitHub to obtain clientId and clientSecret. Follow these steps:

  • Go to GitHub Developer Settings.
  • Create a new OAuth application.
  • Obtain clientId and clientSecret.
  • Set redirectUri to your application's callback URL.

Contributing

Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open an issue on GitHub. To contribute code, fork the repository and submit a pull request.

Credits

Universal Auth is maintained by Thync Labs. Special thanks to contributors for their valuable input and contributions.