oidc-react
Advanced tools
Comparing version 1.5.1 to 1.6.0-alpha
import React, { FC } from 'react'; | ||
import { UserManager } from 'oidc-client'; | ||
import { Location, AuthProviderProps, AuthContextProps } from './AuthContextInterface'; | ||
export declare const AuthContext: React.Context<AuthContextProps | undefined>; | ||
export declare const defaultAuthContext: AuthContextProps; | ||
export declare const AuthContext: React.Context<AuthContextProps>; | ||
export declare const hasCodeInUrl: (location: Location) => boolean; | ||
export declare const initUserManager: (props: AuthProviderProps) => UserManager; | ||
export declare const AuthProvider: FC<AuthProviderProps>; |
@@ -42,6 +42,15 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AuthProvider = exports.initUserManager = exports.hasCodeInUrl = exports.AuthContext = void 0; | ||
exports.AuthProvider = exports.initUserManager = exports.hasCodeInUrl = exports.AuthContext = exports.defaultAuthContext = void 0; | ||
const react_1 = __importStar(require("react")); | ||
const oidc_client_1 = require("oidc-client"); | ||
exports.AuthContext = react_1.default.createContext(undefined); | ||
exports.defaultAuthContext = { | ||
signIn: () => Promise.reject(new Error('AuthContext not loaded yet.')), | ||
signInPopup: () => Promise.reject(new Error('AuthContext not loaded yet.')), | ||
signOut: () => Promise.reject(new Error('AuthContext not loaded yet.')), | ||
signOutRedirect: () => Promise.reject(new Error('AuthContext not loaded yet.')), | ||
userManager: {}, | ||
userData: null, | ||
isLoading: true, | ||
}; | ||
exports.AuthContext = react_1.default.createContext(exports.defaultAuthContext); | ||
exports.hasCodeInUrl = (location) => { | ||
@@ -48,0 +57,0 @@ const searchParams = new URLSearchParams(location.search); |
import { AuthContextProps } from './AuthContextInterface'; | ||
export declare const useAuth: () => AuthContextProps; | ||
export declare const useAuth: (ssr?: boolean | undefined) => AuthContextProps; |
@@ -6,5 +6,5 @@ "use strict"; | ||
const AuthContext_1 = require("./AuthContext"); | ||
exports.useAuth = () => { | ||
exports.useAuth = (ssr) => { | ||
const context = react_1.useContext(AuthContext_1.AuthContext); | ||
if (!context) { | ||
if (!ssr && context === AuthContext_1.defaultAuthContext) { | ||
throw new Error('AuthProvider context is undefined, please verify you are calling useAuth() as child of a <AuthProvider> component.'); | ||
@@ -11,0 +11,0 @@ } |
{ | ||
"name": "oidc-react", | ||
"version": "1.5.1", | ||
"version": "1.6.0-alpha", | ||
"private": false, | ||
@@ -32,3 +32,3 @@ "description": "", | ||
"@types/jest": "^26.0.10", | ||
"@types/node": "^12.12.6", | ||
"@types/node": "^14.14.41", | ||
"@types/react": "^17.0.3", | ||
@@ -35,0 +35,0 @@ "@typescript-eslint/eslint-plugin": "^4.2.0", |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
26712
263
1