Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simple-oauth2-ts-client

Package Overview
Dependencies
Maintainers
0
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-oauth2-ts-client - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

2

package.json
{
"name": "simple-oauth2-ts-client",
"version": "1.0.2",
"version": "1.0.3",
"description": "A TypeScript OAuth 2.0 client library",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -1,1 +0,87 @@

# oauth_client
# OAuth 2.0 Client Library Implementation
So for the Implementation of the Library, i have followed the specs proposed by IETF OAuth Working Group.
So Basic flow of the protocol:
## OAuth2.0 Abstract Flow
![Diagram](https://github.com/user-attachments/assets/014f5341-5c34-49f5-b98e-67c65fcc950e)
## Features
It is a light weight package only has `axios ` as its dependencies, uses `web crypto` which are built-in since Node 18 (but it works with Polyfills on Node 14 and 16).
It is platform agnostic which can be used in both client and server javascript environment .
Following OAuth Grant, it Supports
- Authorization Code
- PKCE
- Client Credentials
- Refresh Token
- Legacy: Implicit Flow
## Installation
Install simple-oauth2-ts-client
with npm
```bash
npm i simple-oauth2-ts-client
```
## Usage/Examples
To get started with initialize the client with the following attributes
```javascript
const client =new OAuthClient({
auth_server: string; //authorisation server domain endpoint
client_id: string; // provided by auth server for public client
client_secret?: string; // provided by auth server for confidential client
redirect_uri: string; // redirection uri for Authorization Code && implicit grant type
authorization_endpoint?: string; // @default /authorize
token_endpoint?: string; // @default /token
authenticationMethod?: "client_secret_basic" | "client_secret_post" | "none";
})
```
This client Object has following method to use for various purposes
```javascript
// This will return redirection uri -->
await client.startAuthFlow(
params: OAuthStartAuthFlow
): Promise<OAuthStartAuthFlowResponse> // can be used for Authorization Code or implicit grants
// to handle successful redirection uri
await client.handleCallback(params: {
uri: string; // redirection back uri
grant_type: OAuth2GrantType; // use authorization_code for Authorization Code grant type
state?: string; // // Optional string that can be sent along to the auth server. This value will
// be sent along with the redirect back to the app verbatim.
code_verifier?: string; // to support PKCE
}): Promise<OAuth2Token>
// to handle refresh token
await client.refreshToken(
refreshToken: string,
params?: RefreshParams
): Promise<OAuth2Token>
```
To generate code verifier and codeChallenge , it exports uility function to do This
`await generateCodeVerifier(): Promise<string>`
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc