@guestlinelabs/react-auth
Advanced tools
Comparing version 4.0.0 to 4.0.1
import React from 'react'; | ||
import { AuthData } from './types'; | ||
import type { Auth0Client } from '@auth0/auth0-spa-js'; | ||
export type AuthFunctions = { | ||
loginWithRedirect: Auth0Client['loginWithRedirect']; | ||
handleRedirectCallback: Auth0Client['handleRedirectCallback']; | ||
logout: Auth0Client['logout']; | ||
getAccessToken: Auth0Client['getTokenSilently']; | ||
}; | ||
import { LoginFunction, HandleRedirectCallbackFunction, LogoutFunction, AuthData, GetAccessTokenFunction } from './types'; | ||
type State = AuthData & { | ||
error: Error | null; | ||
}; | ||
type Auth = State & AuthFunctions; | ||
type Auth = State & { | ||
loginWithRedirect: LoginFunction; | ||
handleRedirectCallback: HandleRedirectCallbackFunction; | ||
logout: LogoutFunction; | ||
getAccessToken: GetAccessTokenFunction; | ||
}; | ||
export interface AuthProviderProps { | ||
@@ -15,0 +13,0 @@ children?: React.ReactNode; |
@@ -52,6 +52,14 @@ "use strict"; | ||
var _b = react_1.default.useReducer(reducer, initialState), state = _b[0], dispatch = _b[1]; | ||
var loginWithRedirect = react_1.default.useCallback(window.guestline.authentication.loginWithRedirect, []); | ||
var handleRedirectCallback = react_1.default.useCallback(window.guestline.authentication.handleRedirectCallback, []); | ||
var logout = react_1.default.useCallback(window.guestline.authentication.logout, []); | ||
var getAccessToken = react_1.default.useCallback(window.guestline.authentication.getAccessToken, []); | ||
var loginWithRedirect = react_1.default.useCallback(function (options) { | ||
return window.guestline.authentication.loginWithRedirect(options); | ||
}, []); | ||
var handleRedirectCallback = react_1.default.useCallback(function (options) { | ||
return window.guestline.authentication.handleRedirectCallback(options); | ||
}, []); | ||
var logout = react_1.default.useCallback(function (options) { | ||
return window.guestline.authentication.logout(options); | ||
}, []); | ||
var getAccessToken = react_1.default.useCallback(function (options) { | ||
return window.guestline.authentication.getAccessToken(options); | ||
}, []); | ||
react_1.default.useEffect(function () { | ||
@@ -58,0 +66,0 @@ var infoSub = function (error, data) { |
@@ -1,5 +0,9 @@ | ||
import { AuthProvider, useAuth, AuthFunctions } from './auth'; | ||
import { AuthData, UserInfo, SubscriptionHandler } from './types'; | ||
type Authentication = AuthFunctions & { | ||
import { AuthProvider, useAuth } from './auth'; | ||
import { AuthData, UserInfo, HandleRedirectCallbackFunction, LoginFunction, LogoutFunction, SubscriptionHandler, GetAccessTokenFunction } from './types'; | ||
type Authentication = { | ||
subscriptions: SubscriptionHandler[]; | ||
loginWithRedirect: LoginFunction; | ||
handleRedirectCallback: HandleRedirectCallbackFunction; | ||
logout: LogoutFunction; | ||
getAccessToken: GetAccessTokenFunction; | ||
}; | ||
@@ -6,0 +10,0 @@ declare global { |
@@ -48,2 +48,28 @@ type LegacyRezlynxSiteAccess = { | ||
}; | ||
interface LoginOptions { | ||
appState?: {}; | ||
loginHint?: string; | ||
redirect_uri?: string; | ||
[key: string]: any; | ||
} | ||
export type LoginFunction = (options?: LoginOptions) => Promise<void>; | ||
interface AccessTokenOptions { | ||
audience?: string; | ||
detailedResponse?: boolean; | ||
ignoreCache?: boolean; | ||
redirect_uri?: string; | ||
scope?: string; | ||
timeoutInSeconds?: number; | ||
} | ||
export type GetAccessTokenFunction = (options?: AccessTokenOptions) => Promise<string>; | ||
interface HandleRedirectCallbackOptions { | ||
url?: string; | ||
} | ||
export type HandleRedirectCallbackFunction = (options?: HandleRedirectCallbackOptions) => Promise<{ | ||
appState?: any; | ||
}>; | ||
export interface LogoutOptions { | ||
returnTo?: string; | ||
} | ||
export type LogoutFunction = (options?: LogoutOptions) => void; | ||
export type UserInfo = { | ||
@@ -50,0 +76,0 @@ id: string; |
{ | ||
"name": "@guestlinelabs/react-auth", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project.", | ||
@@ -21,6 +21,5 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@auth0/auth0-spa-js": "^2.0.5", | ||
"@types/enzyme": "3.10.8", | ||
"@types/enzyme-adapter-react-16": "1.0.6", | ||
"@types/jest": "^26.0.15", | ||
"@types/jest": "26.0.15", | ||
"@types/node": "12.12.14", | ||
@@ -56,2 +55,2 @@ "@types/react": "16.9.15", | ||
} | ||
} | ||
} |
@@ -1,6 +0,18 @@ | ||
import { AuthProvider, useAuth, AuthFunctions } from './auth'; | ||
import { AuthData, UserInfo, SubscriptionHandler } from './types'; | ||
import { AuthProvider, useAuth } from './auth'; | ||
import { | ||
AuthData, | ||
UserInfo, | ||
HandleRedirectCallbackFunction, | ||
LoginFunction, | ||
LogoutFunction, | ||
SubscriptionHandler, | ||
GetAccessTokenFunction, | ||
} from './types'; | ||
type Authentication = AuthFunctions & { | ||
type Authentication = { | ||
subscriptions: SubscriptionHandler[]; | ||
loginWithRedirect: LoginFunction; | ||
handleRedirectCallback: HandleRedirectCallbackFunction; | ||
logout: LogoutFunction; | ||
getAccessToken: GetAccessTokenFunction; | ||
}; | ||
@@ -7,0 +19,0 @@ |
@@ -58,2 +58,34 @@ type LegacyRezlynxSiteAccess = { | ||
interface LoginOptions { | ||
appState?: {}; // State to get back on the login-callback (e.g. to store the page to redirect to after login) | ||
loginHint?: string; // To pre-fill the email/username on the Auth0 login page | ||
redirect_uri?: string; | ||
[key: string]: any; | ||
} | ||
export type LoginFunction = (options?: LoginOptions) => Promise<void>; | ||
interface AccessTokenOptions { | ||
audience?: string; | ||
detailedResponse?: boolean; | ||
ignoreCache?: boolean; | ||
redirect_uri?: string; | ||
scope?: string; | ||
timeoutInSeconds?: number; | ||
} | ||
export type GetAccessTokenFunction = ( | ||
options?: AccessTokenOptions | ||
) => Promise<string>; | ||
interface HandleRedirectCallbackOptions { | ||
url?: string; // URL containing the login code and app state | ||
} | ||
export type HandleRedirectCallbackFunction = ( | ||
options?: HandleRedirectCallbackOptions | ||
) => Promise<{ appState?: any }>; | ||
export interface LogoutOptions { | ||
returnTo?: string; | ||
} | ||
export type LogoutFunction = (options?: LogoutOptions) => void; | ||
export type UserInfo = { | ||
@@ -60,0 +92,0 @@ id: string; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
32453
29
803