Gathering detailed insights and metrics for oauth-pkce
Gathering detailed insights and metrics for oauth-pkce
Gathering detailed insights and metrics for oauth-pkce
Gathering detailed insights and metrics for oauth-pkce
OAUTH PKCE code_verifier and code_challenge Generator for IE 11 and Modern Browsers
npm install oauth-pkce
Typescript
Module System
Node Version
NPM Version
TypeScript (69.84%)
HTML (30.16%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
11 Stars
31 Commits
1 Forks
2 Watchers
15 Branches
2 Contributors
Updated on Apr 22, 2024
Latest Version
0.0.7
Package Id
oauth-pkce@0.0.7
Unpacked Size
13.18 kB
Size
4.72 kB
File Count
10
NPM Version
6.14.18
Node Version
14.21.3
Published on
Apr 22, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
25
Proof Key for Code Exchange Spec
A small (409-Byte gzipped) zero-dependency helper function for generating a high-entropy cryptographic random "code_verifier" (using Web Crypto API) and its "code_challenge" based on RFC 7636. (i.e. BASE64URL-ENCODE(SHA256(ASCII(code_verifier)))
)
This package does NOT use Math.random() which does not provide cryptographically secure random numbers, and should not use them for anything related to security.
This package is for browsers only (including IE 11), it uses Web Crypto API for generating random strings and SHA-256 hashing.
https://cdn.jsdelivr.net/npm/oauth-pkce@latest/dist/oauth-pkce.min.js
or with version
https://cdn.jsdelivr.net/npm/oauth-pkce@0.0.2/dist/oauth-pkce.min.js
npm i oauth-pkce
Typescript Ready
1import getPkce from 'oauth-pkce'; 2 3// create a verifier of 43 characters long 4getPkce(43, (error, { verifier, challenge }) => { 5 if (!error) { 6 console.log({ verifier, challenge }); 7 } 8}); 9 10// { verifier: "uxr7S_52pCoOPFpPPYWNvdw76k3ZnSN-J0PvD0iPL9B", challenge: "8L_tpjLD-Vcc3-G6ea2ifym8AQrushivXHMib5zPp1A" }
Use directly from CDN
1<script src="https://cdn.jsdelivr.net/npm/oauth-pkce@0.0.2/dist/oauth-pkce.min.js" async defer></script>; 2 3getPkce(43, (error, { verifier, challenge }) => { 4 if (!error) { 5 console.log({ verifier, challenge }); 6 } 7});
React
1import React, { useEffect, useState } from 'react'; 2import getPkce from 'oauth-pkce'; 3 4function Pkce() { 5 const { pkce, setPkce } = useState({}); 6 7 useEffect(() => { 8 // getPkce relies on the window object for its crypto api 9 // put in in useEffect 10 getPkce(50, (error, { verifier, challenge }) => { 11 setPkce({ verifier, challenge }); 12 }); 13 }, []); 14 15 return ( 16 <div> 17 {pkce.verifier} | {pkce.challenge} 18 </div> 19 ); 20}
This package uses callback style for minimising code size and compatibility with IE 11. Wrapp it in a Promise if you prefer async await style.
1const { verifier, challenge } = await new Promise((resolve) => { 2 getPkce(43, (error, { verifier, challenge }) => { 3 if (error) throw error; 4 resolve({ verifier, challenge }); 5 }); 6});
For node environment, use crypto module natively from node.
1import crypto from 'crypto'; 2 3const base64 = crypto.createHash('sha256').update(code_verifier).digest('base64'); 4const base64UriEncoded = base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, ''); 5 6const isValid = base64UriEncoded === code_challenge;
code_challenge is a Base64URL encoded string (RFC 4648). To verify the code_verifier
you need to convert the base64 value of crypto.createHash('sha256').update(code_verifier).digest('base64')
to a base64url encoded string.
In getPkce()
, base64url removes the pad characters "=" from code_challenge
1getPkce( 2 codeVerifierLength: number = 43, 3 callback: (error: Error | null, value: { verifier: string; challenge: string }) 4)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 1/7 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
43 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More