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
1
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.5.2 to 1.6.0

16

dist/AuthContext.js

@@ -37,2 +37,3 @@ "use strict";

token: '',
login: () => null,
logOut: () => null,

@@ -52,6 +53,7 @@ error: null,

let interval;
// Set default values and override from passed config
const { decodeToken = true, scope = '', preLogin = () => null, postLogin = () => null } = authConfig;
// Set default values for internal config object
const { autoLogin = true, decodeToken = true, scope = '', preLogin = () => null, postLogin = () => null, } = authConfig;
const config = {
...authConfig,
autoLogin: autoLogin,
decodeToken: decodeToken,

@@ -72,2 +74,6 @@ scope: scope,

}
function login() {
setLoginInProgress(true);
(0, authentication_1.logIn)(config);
}
function handleTokenResponse(response) {

@@ -148,4 +154,4 @@ setToken(response.access_token);

// First page visit
setLoginInProgress(true);
(0, authentication_1.logIn)(config);
if (config.autoLogin)
(0, authentication_1.logIn)(config);
}

@@ -164,4 +170,4 @@ else {

}, []); // eslint-disable-line
return (react_1.default.createElement(exports.AuthContext.Provider, { value: { tokenData, token, idToken, logOut, error, loginInProgress } }, children));
return (react_1.default.createElement(exports.AuthContext.Provider, { value: { tokenData, token, idToken, login, logOut, error, loginInProgress } }, children));
};
exports.AuthProvider = AuthProvider;

@@ -35,2 +35,3 @@ import { ReactNode } from 'react';

logOut: () => void;
login: () => void;
error: string | null;

@@ -52,2 +53,3 @@ tokenData?: TTokenData;

decodeToken?: boolean;
autoLogin?: boolean;
extraAuthParams?: {

@@ -70,2 +72,3 @@ [key: string]: string | boolean | number;

decodeToken: boolean;
autoLogin: boolean;
extraAuthParams?: {

@@ -72,0 +75,0 @@ [key: string]: string | boolean | number;

{
"name": "react-oauth2-code-pkce",
"version": "1.5.2",
"version": "1.6.0",
"description": "Plug-and-play react package for OAuth2 Authorization Code flow with PKCE",

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

@@ -41,3 +41,10 @@ # react-oauth2-pkce · [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/soofstad/react-oauth2-pkce/blob/main/LICENSE) [![npm version](https://img.shields.io/npm/v/react-oauth2-code-pkce)](https://www.npmjs.com/package/react-oauth2-code-pkce) ![CI](https://github.com/soofstad/react-oauth2-pkce/actions/workflows/tests.yaml/badge.svg)

function LoginInfo() {
const { tokenData, token, logOut, error, loginInProgress } = useContext(AuthContext)
const {
tokenData,
token,
login,
logOut,
error,
loginInProgress
} = useContext(AuthContext)

@@ -50,3 +57,5 @@ // Stops the webpage from flickering while logging in

<>
<div style={{ color: 'red' }}>An error occurred during authentication: {error}</div>
<div style={{ color: 'red' }}>
An error occurred during authentication: {error}
</div>
<button onClick={() => logOut()}>Logout</button>

@@ -59,4 +68,6 @@ </>

<>
<div style={{ backgroundColor: 'red' }}>You are not logged in</div>
<button onClick={() => window.location.reload()}>Login</button>
<div style={{ backgroundColor: 'red' }}>
You are not logged in
</div>
<button onClick={() => login()}>Login</button>
</>

@@ -125,2 +136,5 @@ )

decodeToken?: boolean // default: true
// By default, it will automatically redirect the user to the login server if not already logged in.
// If set to false, you need to call the "login()" function to login (e.g. with a "Login" button)
autoLogin?: boolean // default: true
// Can be used to provide any non-standard parameters to the authorization request

@@ -127,0 +141,0 @@ extraAuthParams?: { [key: string]: string | boolean | number } // default: null

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