Git Product home page Git Product logo

isabella232 / easy-pkce Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ringcentral/easy-pkce

0.0 0.0 0.0 5 KB

EASY-PKCE project is a small lib that generates strings for PKCE, as known as Proof Key for Code Exchange. PKCE is a mechanism that came into being to make the use of OAuth 2.0 Authorization Code grant more secure in certain cases. It was originally designed to protect mobile apps, but its ability to prevent authorization code injection makes it useful for every OAuth client, even web apps that use a client secret.

JavaScript 10.70% TypeScript 89.30%

easy-pkce's Introduction

EASY-PKCE

Build Status NPM version

Description

EASY-PKCE project is a small lib that generates strings for PKCE, as known as Proof Key for Code Exchange. PKCE is a mechanism that came into being to make the use of OAuth 2.0 Authorization Code grant more secure in certain cases. It was originally designed to protect mobile apps, but its ability to prevent authorization code injection makes it useful for every OAuth client, even web apps that use a client secret.

Usages

import {
  generateCodeChallenge,
  generateCodeVerifier,
  generateState,
  generateRandomString,
} from 'easy-pkce';

// get a base64url-encoded random string from a 32-octet sequence
const randomString = generateRandomString(32);

// get a url safe code verifier from a random 42-octet sequence
const codeVerifier_1 = generateCodeVerifier(42);
const codeVerifier_2 = generateCodeVerifier(); // default octet length is 32

// get a url safe state from a random 12-octet sequence
const state_1 = generateState(12);
const state_2 = generateState(); // default octet length is 32

// get the code challenge from the code verifier
const codeChallenge_1 = generateCodeChallenge(codeVerifier_1, 'plain'); // plain version
const codeChallenge_2 = generateCodeChallenge(codeVerifier_2, 'S256'); // S256 version

// get a pair of code verifier and code challenge
const {codeVerifier, codeChallenge} = generatePair("S256", 32);

LICENSE MIT

easy-pkce's People

Contributors

lipwang2023 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.