Socket
Socket
Sign inDemoInstall

react-oidc-context

Package Overview
Dependencies
6
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.1.0

5

dist/esm/react-oidc-context.js

@@ -113,3 +113,6 @@ // src/AuthContext.ts

const [state, dispatch] = useReducer(reducer, initialAuthState);
const userManagerContext = useMemo(() => Object.assign({ settings: userManager.settings }, Object.fromEntries(userManagerContextKeys.map((key) => {
const userManagerContext = useMemo(() => Object.assign({
settings: userManager.settings,
events: userManager.events
}, Object.fromEntries(userManagerContextKeys.map((key) => {
var _a, _b;

@@ -116,0 +119,0 @@ return [

17

dist/types/react-oidc-context.d.ts

@@ -12,2 +12,3 @@ import type { QuerySessionStatusArgs } from 'oidc-client-ts';

import { UserManager } from 'oidc-client-ts';
import type { UserManagerEvents } from 'oidc-client-ts';
import { UserManagerSettings } from 'oidc-client-ts';

@@ -28,2 +29,3 @@

readonly settings: UserManagerSettings;
readonly events: UserManagerEvents;
clearStaleState(): Promise<void>;

@@ -85,9 +87,6 @@ removeUser(): Promise<void>;

* On remove user hook. Can be a async function.
*/
onRemoveUser?: () => Promise<void> | void;
/**
* On sign out redirect hook. Can be a async function.
* Here you can change the url after the logout.
* Here you can change the url after the user is removed.
*
* ```jsx
* const onSignOutRedirect = (): void => {
* const onRemoveUser = (): void => {
* // go to home after logout

@@ -98,5 +97,9 @@ * window.location.pathname = ""

*/
onRemoveUser?: () => Promise<void> | void;
/**
* @deprecated On sign out redirect hook. Can be a async function.
*/
onSignoutRedirect?: () => Promise<void> | void;
/**
* On sign out popup hook. Can be a async function.
* @deprecated On sign out popup hook. Can be a async function.
*/

@@ -103,0 +106,0 @@ onSignoutPopup?: () => Promise<void> | void;

@@ -151,3 +151,6 @@ var __create = Object.create;

const [state, dispatch] = (0, import_react2.useReducer)(reducer, initialAuthState);
const userManagerContext = (0, import_react2.useMemo)(() => Object.assign({ settings: userManager.settings }, Object.fromEntries(userManagerContextKeys.map((key) => {
const userManagerContext = (0, import_react2.useMemo)(() => Object.assign({
settings: userManager.settings,
events: userManager.events
}, Object.fromEntries(userManagerContextKeys.map((key) => {
var _a, _b;

@@ -154,0 +157,0 @@ return [

{
"name": "react-oidc-context",
"version": "2.0.0",
"version": "2.1.0",
"description": "OpenID Connect & OAuth2 authentication using react context api as state management",

@@ -42,3 +42,3 @@ "repository": {

"peerDependencies": {
"oidc-client-ts": "^2.0.0-rc.4",
"oidc-client-ts": "^2.0.0",
"react": ">=16.8.0"

@@ -45,0 +45,0 @@ },

@@ -40,3 +40,3 @@ # react-oidc-context

```bash
npm install react-oidc-context
npm install oidc-client-ts react-oidc-context --save
```

@@ -209,2 +209,29 @@

### Adding event listeners
The underlying [`UserManagerEvents`](https://authts.github.io/oidc-client-ts/classes/UserManagerEvents.html) instance can be imperatively managed with the `useAuth` hook.
```jsx
// src/App.jsx
import React from "react";
import { useAuth } from "react-oidc-context";
function App() {
const auth = useAuth();
React.useEffect(() => {
// the `return` is important - addAccessTokenExpiring() returns a cleanup function
return auth.events.addAccessTokenExpiring(() => {
if (alert("You're about to be signed out due to inactivity. Press continue to stay signed in.")) {
auth.signinSilent()
}
})
}, [auth.events, auth.signinSilent])
return <button onClick={auth.signinRedirect}>Log in</button>;
}
export default App;
```
## Contributing

@@ -211,0 +238,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc