JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6437965
  • Score
    100M100P100Q289931F
  • License MIT

Generate or verify a Proof Key for Code Exchange (PKCE) challenge pair

Package Exports

  • pkce-challenge

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pkce-challenge) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

pkce-challenge

Generate or verify a Proof Key for Code Exchange (PKCE) challenge pair.

Read more about PKCE.

Installation

npm install pkce-challenge

Usage

Default length for the verifier is 43

const pkceChallenge = require("pkce-challenge");

pkceChallenge();

gives something like:

{
    code_verifier: 'u1ta-MQ0e7TcpHjgz33M2DcBnOQu~aMGxuiZt0QMD1C',
    code_challenge: 'CUZX5qE8Wvye6kS_SasIsa8MMxacJftmWdsIA_iKp3I'
}

Specify a verifier length

const challenge = pkceChallenge(128);

challenge.code_verifier.length === 128; // true

Challenge verification

const { verifyChallenge } = require("pkce-challenge");

verifyChallenge(challenge.code_verifier, challenge.code_challenge) === true; // true

Challenge generation from existing code verifier

const { generateChallenge } = require("pkce-challenge");

generateChallenge(challenge.code_verifier) === challenge.code_challenge; // true