@entur/auth-provider
Advanced tools
Comparing version 1.1.0 to 1.1.1
import React from 'react'; | ||
import { Auth0Config } from './typings'; | ||
interface Props { | ||
@@ -3,0 +4,0 @@ keycloakConfigUrl?: string; |
import React from 'react'; | ||
import { Auth, User } from './typings'; | ||
export declare const defaultAuthState: { | ||
@@ -11,2 +12,2 @@ isLoading: boolean; | ||
}; | ||
export declare const AuthContext: React.Context<Auth>; | ||
export declare const AuthContext: React.Context<Auth<User>>; |
export { AuthProvider as default } from './AuthProvider'; | ||
export declare const useAuth: () => Auth; | ||
export declare const useAuth: () => import("./typings").Auth<import("./typings").User>; |
@@ -18,22 +18,22 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
}; | ||
var AuthContext = React__default.createContext(defaultAuthState); | ||
function createAuthContext() { | ||
return React__default.createContext(defaultAuthState); | ||
} | ||
var AuthContext = createAuthContext(); | ||
var Auth0AuthProvider = function Auth0AuthProvider(_ref) { | ||
var children = _ref.children, | ||
claimsNamespace = _ref.claimsNamespace, | ||
loginAutomatically = _ref.loginAutomatically; | ||
claimsNamespace = _ref.claimsNamespace, | ||
loginAutomatically = _ref.loginAutomatically; | ||
var _useAuth = auth0React.useAuth0(), | ||
isLoading = _useAuth.isLoading, | ||
isAuthenticated = _useAuth.isAuthenticated, | ||
user = _useAuth.user, | ||
loginWithRedirect = _useAuth.loginWithRedirect, | ||
getIdTokenClaims = _useAuth.getIdTokenClaims, | ||
getAccessTokenSilently = _useAuth.getAccessTokenSilently, | ||
logout = _useAuth.logout; | ||
isLoading = _useAuth.isLoading, | ||
isAuthenticated = _useAuth.isAuthenticated, | ||
user = _useAuth.user, | ||
loginWithRedirect = _useAuth.loginWithRedirect, | ||
getIdTokenClaims = _useAuth.getIdTokenClaims, | ||
getAccessTokenSilently = _useAuth.getAccessTokenSilently, | ||
logout = _useAuth.logout; | ||
var _useState = React.useState(), | ||
roleAssignments = _useState[0], | ||
setRoleAssignments = _useState[1]; | ||
roleAssignments = _useState[0], | ||
setRoleAssignments = _useState[1]; | ||
React.useEffect(function () { | ||
@@ -43,3 +43,5 @@ var getClaims = function getClaims() { | ||
return Promise.resolve(getIdTokenClaims()).then(function (idTokenClaims) { | ||
setRoleAssignments(idTokenClaims[claimsNamespace]); | ||
if (idTokenClaims) { | ||
setRoleAssignments(idTokenClaims[claimsNamespace]); | ||
} | ||
}); | ||
@@ -50,3 +52,2 @@ } catch (e) { | ||
}; | ||
if (isAuthenticated && claimsNamespace !== undefined) { | ||
@@ -56,3 +57,2 @@ getClaims(); | ||
}, [isAuthenticated, getIdTokenClaims]); | ||
if (!isAuthenticated && !isLoading) { | ||
@@ -63,3 +63,2 @@ if (loginAutomatically) { | ||
} | ||
return React__default.createElement(AuthContext.Provider, { | ||
@@ -84,6 +83,6 @@ value: { | ||
var auth0Config = _ref.auth0Config, | ||
auth0ClaimsNamespace = _ref.auth0ClaimsNamespace, | ||
children = _ref.children, | ||
_ref$loginAutomatical = _ref.loginAutomatically, | ||
loginAutomatically = _ref$loginAutomatical === void 0 ? true : _ref$loginAutomatical; | ||
auth0ClaimsNamespace = _ref.auth0ClaimsNamespace, | ||
children = _ref.children, | ||
_ref$loginAutomatical = _ref.loginAutomatically, | ||
loginAutomatically = _ref$loginAutomatical === void 0 ? true : _ref$loginAutomatical; | ||
return React__default.createElement(auth0React.Auth0Provider, Object.assign({ | ||
@@ -90,0 +89,0 @@ useRefreshToken: true, |
@@ -15,22 +15,22 @@ import React, { useState, useEffect, useContext } from 'react'; | ||
}; | ||
var AuthContext = React.createContext(defaultAuthState); | ||
function createAuthContext() { | ||
return React.createContext(defaultAuthState); | ||
} | ||
var AuthContext = createAuthContext(); | ||
var Auth0AuthProvider = function Auth0AuthProvider(_ref) { | ||
var children = _ref.children, | ||
claimsNamespace = _ref.claimsNamespace, | ||
loginAutomatically = _ref.loginAutomatically; | ||
claimsNamespace = _ref.claimsNamespace, | ||
loginAutomatically = _ref.loginAutomatically; | ||
var _useAuth = useAuth0(), | ||
isLoading = _useAuth.isLoading, | ||
isAuthenticated = _useAuth.isAuthenticated, | ||
user = _useAuth.user, | ||
loginWithRedirect = _useAuth.loginWithRedirect, | ||
getIdTokenClaims = _useAuth.getIdTokenClaims, | ||
getAccessTokenSilently = _useAuth.getAccessTokenSilently, | ||
logout = _useAuth.logout; | ||
isLoading = _useAuth.isLoading, | ||
isAuthenticated = _useAuth.isAuthenticated, | ||
user = _useAuth.user, | ||
loginWithRedirect = _useAuth.loginWithRedirect, | ||
getIdTokenClaims = _useAuth.getIdTokenClaims, | ||
getAccessTokenSilently = _useAuth.getAccessTokenSilently, | ||
logout = _useAuth.logout; | ||
var _useState = useState(), | ||
roleAssignments = _useState[0], | ||
setRoleAssignments = _useState[1]; | ||
roleAssignments = _useState[0], | ||
setRoleAssignments = _useState[1]; | ||
useEffect(function () { | ||
@@ -40,3 +40,5 @@ var getClaims = function getClaims() { | ||
return Promise.resolve(getIdTokenClaims()).then(function (idTokenClaims) { | ||
setRoleAssignments(idTokenClaims[claimsNamespace]); | ||
if (idTokenClaims) { | ||
setRoleAssignments(idTokenClaims[claimsNamespace]); | ||
} | ||
}); | ||
@@ -47,3 +49,2 @@ } catch (e) { | ||
}; | ||
if (isAuthenticated && claimsNamespace !== undefined) { | ||
@@ -53,3 +54,2 @@ getClaims(); | ||
}, [isAuthenticated, getIdTokenClaims]); | ||
if (!isAuthenticated && !isLoading) { | ||
@@ -60,3 +60,2 @@ if (loginAutomatically) { | ||
} | ||
return React.createElement(AuthContext.Provider, { | ||
@@ -81,6 +80,6 @@ value: { | ||
var auth0Config = _ref.auth0Config, | ||
auth0ClaimsNamespace = _ref.auth0ClaimsNamespace, | ||
children = _ref.children, | ||
_ref$loginAutomatical = _ref.loginAutomatically, | ||
loginAutomatically = _ref$loginAutomatical === void 0 ? true : _ref$loginAutomatical; | ||
auth0ClaimsNamespace = _ref.auth0ClaimsNamespace, | ||
children = _ref.children, | ||
_ref$loginAutomatical = _ref.loginAutomatically, | ||
loginAutomatically = _ref$loginAutomatical === void 0 ? true : _ref$loginAutomatical; | ||
return React.createElement(Auth0Provider, Object.assign({ | ||
@@ -87,0 +86,0 @@ useRefreshToken: true, |
{ | ||
"name": "@entur/auth-provider", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "React components and helpers for authentication", | ||
@@ -66,4 +66,4 @@ "author": "entur/nrp", | ||
"dependencies": { | ||
"@auth0/auth0-react": "1.2.0" | ||
"@auth0/auth0-react": "1.12.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23473
229
+ Added@auth0/auth0-react@1.12.1(transitive)
+ Addedreact-dom@18.3.1(transitive)
+ Addedscheduler@0.23.2(transitive)
- Removed@auth0/auth0-react@1.2.0(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedreact@17.0.2(transitive)
- Removedreact-dom@17.0.2(transitive)
- Removedscheduler@0.20.2(transitive)
Updated@auth0/auth0-react@1.12.1