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

react-oauth2-code-pkce

Package Overview
Dependencies
Maintainers
0
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-oauth2-code-pkce - npm Package Compare versions

Comparing version 1.21.0 to 1.21.1

26

dist/AuthContext.js

@@ -55,4 +55,7 @@ "use strict";

const [loginMethod, setLoginMethod] = (0, Hooks_1.default)(`${config.storageKeyPrefix}loginMethod`, 'redirect', config.storage);
const [tokenData, setTokenData] = (0, react_1.useState)();
const [idTokenData, setIdTokenData] = (0, react_1.useState)();
const tokenData = (0, react_1.useMemo)(() => {
if (config.decodeToken)
return (0, decodeJWT_1.decodeAccessToken)(token);
}, [token]);
const idTokenData = (0, react_1.useMemo)(() => (0, decodeJWT_1.decodeIdToken)(idToken), [idToken]);
const [error, setError] = (0, react_1.useState)(null);

@@ -65,4 +68,2 @@ function clearStorage() {

setIdToken(undefined);
setTokenData(undefined);
setIdTokenData(undefined);
setLoginInProgress(false);

@@ -191,19 +192,2 @@ }

const didFetchTokens = (0, react_1.useRef)(false);
// Load token-/idToken-data when tokens change
(0, react_1.useEffect)(() => {
try {
if (idToken)
setIdTokenData((0, decodeJWT_1.decodeJWT)(idToken));
}
catch (e) {
console.warn(`Failed to decode idToken: ${e.message}`);
}
try {
if (token && config.decodeToken)
setTokenData((0, decodeJWT_1.decodeJWT)(token));
}
catch (e) {
console.warn(`Failed to decode access token: ${e.message}`);
}
}, [token, idToken]);
// Runs once on page load

@@ -210,0 +194,0 @@ (0, react_1.useEffect)(() => {

2

dist/decodeJWT.d.ts

@@ -6,1 +6,3 @@ import type { TTokenData } from './types';

export declare const decodeJWT: (token: string) => TTokenData;
export declare const decodeAccessToken: (token: string | null | undefined) => TTokenData | undefined;
export declare const decodeIdToken: (idToken: string | null | undefined) => TTokenData | undefined;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.decodeJWT = void 0;
exports.decodeIdToken = exports.decodeAccessToken = exports.decodeJWT = void 0;
/**

@@ -24,1 +24,23 @@ * Decodes the base64 encoded JWT. Returns a TToken.

exports.decodeJWT = decodeJWT;
const decodeAccessToken = (token) => {
if (!token || !token.length)
return undefined;
try {
return (0, exports.decodeJWT)(token);
}
catch (e) {
console.warn(`Failed to decode access token: ${e.message}`);
}
};
exports.decodeAccessToken = decodeAccessToken;
const decodeIdToken = (idToken) => {
if (!idToken || !idToken.length)
return undefined;
try {
return (0, exports.decodeJWT)(idToken);
}
catch (e) {
console.warn(`Failed to decode idToken: ${e.message}`);
}
};
exports.decodeIdToken = decodeIdToken;
{
"name": "react-oauth2-code-pkce",
"version": "1.21.0",
"version": "1.21.1",
"description": "Provider agnostic react package for OAuth2 Authorization Code flow with PKCE",

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

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