0.0.12 • Published 4 months ago

sso-clients v0.0.12

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

SSO Clients

Clients

Installation

npm install sso-clients

OR

yarn add sso-clients

Usage

Import the Google Client

import { GoogleOAuth2 } from "sso-clients";

Initialize the Client

const googleOAuth = new GoogleOAuth2(
  "YOUR_GOOGLE_CLIENT_ID",
  "YOUR_GOOGLE_CLIENT_SECRET",
  "YOUR_CALLBACK_URL",
  ["email", "profile", "openid"],
);

Import the GitHub Client

import { GithubOAuth2 } from "sso-clients";

Initialize the Client

const githubOAuth = new GithubOAuth2(
  "YOUR_GITHUB_CLIENT_ID",
  "YOUR_GITHUB_CLIENT_SECRET",
  "YOUR_CALLBACK_URL",
  ['user:email']
);

Import the Auth0 Client

import { Auth0OAuth2 } from "sso-clients";

Initialize the Client

const auth0OAuth = new Auth0OAuth2(
  "YOUR_AUTH0_CLIENT_ID",
  "YOUR_AUTH0_CLIENT_SECRET",
  "YOUR_CALLBACK_URL",
  "YOUR_AUTH0_DOMAIN",
  ["openid", "profile", "email", "offline_access"],
);

Available methods for a client

  • getName(): string: Returns the name of the provider.

  • getLoginURL(): string: Returns the URL for provider login.

  • getTokens(code: string): Promise<Tokens>: Exchanges the authorization code for the access token. Returns a Promise that resolves to the tokens (access token, token type, expires in, and optional refresh token).

  • refreshTokens(refreshToken: string): Promise<Tokens>: Refreshes the access token using the provided refresh token. Returns a Promise that resolves to the updated tokens.

  • getUserID(accessToken: string): Promise<string>: Fetches the user ID using the provided access token.

  • getUserEmail(accessToken: string): Promise<string>: Retrieves the user's email using the access token. Returns a Promise that resolves to the user's email.

  • isEmailVerified(accessToken: string): Promise<boolean>: Checks if the user's email is verified using the access token. Returns a Promise that resolves to a boolean indicating email verification status.

  • getUserName(accessToken: string): Promise<string>: Retrieves the user's name using the access token. Returns a Promise that resolves to the user's name.

  • getUser(accessToken: string): Promise<User>: Retrieves the user's information (sub, email, email_verified, name) using the access token. Returns a Promise that resolves to the user object.

0.0.12

4 months ago

0.0.11

7 months ago

0.0.10

9 months ago

0.0.9

10 months ago

0.0.8

10 months ago

0.0.7

10 months ago

0.0.6

10 months ago

0.0.5

10 months ago

0.0.4

10 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago

0.0.0

10 months ago