@auth0/auth0-react
Advanced tools
Comparing version 0.4.0 to 1.0.0
# Change Log | ||
## [v1.0.0](https://github.com/auth0/auth0-react/tree/v1.0.0) (2020-06-19) | ||
**Breaking Change** | ||
- Allow custom `returnTo` in `withAuthenticationRequired` [\#41](https://github.com/auth0/auth0-react/pull/41) ([adamjmcgrath](https://github.com/adamjmcgrath)) | ||
## [v0.4.0](https://github.com/auth0/auth0-react/tree/v0.4.0) (2020-06-05) | ||
@@ -4,0 +10,0 @@ |
@@ -98,3 +98,3 @@ /// <reference types="react" /> | ||
* ```js | ||
* auth0.logout(); | ||
* auth0.logout({ returnTo: window.location.origin }); | ||
* ``` | ||
@@ -104,3 +104,3 @@ * | ||
* the parameters provided as arguments, to clear the Auth0 session. | ||
* If the `federated` option is specified it also clears the Identity Provider session. | ||
* If the `federated` option is specified, it also clears the Identity Provider session. | ||
* If the `localOnly` option is specified, it only clears the application session. | ||
@@ -107,0 +107,0 @@ * It is invalid to set both the `federated` and `localOnly` options to `true`, |
@@ -82,3 +82,3 @@ import React from 'react'; | ||
/** | ||
* Maximum allowable elasped time (in seconds) since authentication. | ||
* Maximum allowable elapsed time (in seconds) since authentication. | ||
* If the last time the user authenticated is greater than this value, | ||
@@ -114,3 +114,3 @@ * the user must be reauthenticated. | ||
* | ||
* Provides the Auth0Context to it's child components. | ||
* Provides the Auth0Context to its child components. | ||
*/ | ||
@@ -117,0 +117,0 @@ declare const Auth0Provider: (opts: Auth0ProviderOptions) => JSX.Element; |
export { default as Auth0Provider, Auth0ProviderOptions, } from './auth0-provider'; | ||
export { default as useAuth0 } from './use-auth0'; | ||
export { default as withAuth0, WithAuth0Props } from './with-auth0'; | ||
export { default as withAuthenticationRequired } from './with-authentication-required'; | ||
export { default as withAuthenticationRequired, WithAuthenticationRequiredOptions, } from './with-authentication-required'; | ||
export { default as Auth0Context, Auth0ContextInterface, RedirectLoginOptions, } from './auth0-context'; | ||
@@ -6,0 +6,0 @@ export { PopupLoginOptions, PopupConfigOptions, GetIdTokenClaimsOptions, GetTokenWithPopupOptions, LogoutOptions, CacheLocation, IdToken, } from '@auth0/auth0-spa-js'; |
import React from 'react'; | ||
import { RedirectLoginOptions } from '@auth0/auth0-spa-js'; | ||
/** | ||
* Options for the withAuthenticationRequired Higher Order Component | ||
*/ | ||
export interface WithAuthenticationRequiredOptions { | ||
/** | ||
* ```js | ||
* withAuthenticationRequired(Profile, { | ||
* returnTo: '/profile' | ||
* }) | ||
* ``` | ||
* | ||
* or | ||
* | ||
* ```js | ||
* withAuthenticationRequired(Profile, { | ||
* returnTo: () => window.location.hash.substr(1) | ||
* }) | ||
* ``` | ||
* | ||
* Add a path for the `onRedirectCallback` handler to return the user to after login. | ||
*/ | ||
returnTo?: string | (() => string); | ||
/** | ||
* ```js | ||
* withAuthenticationRequired(Profile, { | ||
* onRedirecting: () => <div>Redirecting you to the login...</div> | ||
* }) | ||
* ``` | ||
* | ||
* Render a message to show that the user is being redirected to the login. | ||
*/ | ||
onRedirecting?: () => JSX.Element; | ||
/** | ||
* ```js | ||
* withAuthenticationRequired(Profile, { | ||
* loginOptions: { | ||
* appState: { | ||
* customProp: 'foo' | ||
* } | ||
* } | ||
* }) | ||
* ``` | ||
* | ||
* Pass additional login options, like extra `appState` to the login page. | ||
* This will be merged with the `returnTo` option used by the `onRedirectCallback` handler. | ||
*/ | ||
loginOptions?: RedirectLoginOptions; | ||
} | ||
/** | ||
* ```js | ||
@@ -10,4 +59,4 @@ * const MyProtectedComponent = withAuthenticationRequired(MyComponent); | ||
*/ | ||
declare const withAuthenticationRequired: <P extends object>(Component: React.ComponentType<P>, onRedirecting?: () => JSX.Element) => React.FC<P>; | ||
declare const withAuthenticationRequired: <P extends object>(Component: React.ComponentType<P>, options?: WithAuthenticationRequiredOptions) => React.FC<P>; | ||
export default withAuthenticationRequired; | ||
//# sourceMappingURL=with-authentication-required.d.ts.map |
{ | ||
"author": "Auth0", | ||
"name": "@auth0/auth0-react", | ||
"version": "0.4.0", | ||
"version": "1.0.0", | ||
"description": "Auth0 SDK for React Single Page Applications (SPA)", | ||
@@ -27,4 +27,19 @@ "keywords": [ | ||
"test": "jest --coverage", | ||
"prepack": "npm run test && npm run build", | ||
"docs": "typedoc --options typedoc.js src node_modules/@auth0/auth0-spa-js/dist/typings/global.d.ts", | ||
"prepack": "npm run test && npm run build" | ||
"install:examples": "npm i --prefix=examples/cra-react-router --no-package-lock; npm i --prefix=examples/gatsby-app --no-package-lock; npm i --prefix=examples/nextjs-app --no-package-lock; npm ci --prefix=examples/users-api", | ||
"start:cra": "npm start --prefix=examples/cra-react-router", | ||
"start:gatsby": "npm start --prefix=examples/gatsby-app", | ||
"start:nextjs": "npm run dev --prefix=examples/nextjs-app", | ||
"start:api": "npm start --prefix=examples/users-api", | ||
"test:cra": "start-server-and-test start:api 3001 start:cra 3000 cypress:run", | ||
"test:cra:watch": "start-server-and-test start:api 3001 start:cra 3000 cypress:open", | ||
"test:gatsby": "start-server-and-test start:api 3001 start:gatsby 3000 cypress:run", | ||
"test:gatsby:watch": "start-server-and-test start:api 3001 start:gatsby 3000 cypress:open", | ||
"test:nextjs": "start-server-and-test start:api 3001 start:nextjs 3000 cypress:run", | ||
"test:nextjs:watch": "start-server-and-test start:api 3001 start:nextjs 3000 cypress:open", | ||
"test:integration": "npm run test:cra; npm run test:gatsby; npm run test:nextjs", | ||
"cypress:run": "cypress run", | ||
"cypress:open": "cypress open", | ||
"codecov": "codecov" | ||
}, | ||
@@ -51,2 +66,4 @@ "repository": { | ||
"@typescript-eslint/parser": "^2.30.0", | ||
"codecov": "^3.7.0", | ||
"cypress": "^4.7.0", | ||
"eslint": "^6.8.0", | ||
@@ -70,2 +87,3 @@ "eslint-plugin-react": "^7.19.0", | ||
"rollup-plugin-typescript2": "^0.27.0", | ||
"start-server-and-test": "^1.11.0", | ||
"ts-jest": "^25.4.0", | ||
@@ -72,0 +90,0 @@ "tslib": "^1.11.1", |
@@ -5,9 +5,7 @@ # @auth0/auth0-react | ||
[![CircleCI](https://circleci.com/gh/auth0/auth0-react.svg?style=svg&circle-token=b7d4097b3e2d3d3d086b26df6b20fb0f51d8ca09)](https://circleci.com/gh/auth0/auth0-react) | ||
[![CircleCI](https://img.shields.io/circleci/build/github/auth0/auth0-react.svg?branch=master&style=flat)](https://circleci.com/gh/auth0/auth0-react) | ||
[![License](https://img.shields.io/:license-mit-blue.svg?style=flat)](https://opensource.org/licenses/MIT) | ||
[![npm](https://img.shields.io/npm/v/@auth0/auth0-react.svg?style=flat)](https://www.npmjs.com/package/@auth0/auth0-react) | ||
[![codecov](https://img.shields.io/codecov/c/github/auth0/auth0-react/master.svg?style=flat)](https://codecov.io/gh/auth0/auth0-react) | ||
### Beta | ||
**@auth0/auth0-react** is in Beta in order to get feedback to shape its design. As we move towards general availability please be aware that releases may contain breaking changes, but we will do our best to communicate them. | ||
## Table of Contents | ||
@@ -20,2 +18,3 @@ | ||
- [Support + Feedback](#support--feedback) | ||
- [Troubleshooting](#troubleshooting) | ||
- [Vulnerability Reporting](#vulnerability-reporting) | ||
@@ -28,2 +27,3 @@ - [What is Auth0](#what-is-auth0) | ||
- [API Reference](https://auth0.github.io/auth0-react/) | ||
- [Quickstart Guide](https://auth0.com/docs/quickstart/spa/auth0-react) | ||
@@ -94,3 +94,6 @@ ## Installation | ||
<div> | ||
Hello {user.name} <button onClick={logout}>Log out</button> | ||
Hello {user.name}{' '} | ||
<button onClick={() => logout({ returnTo: window.location.origin })}> | ||
Log out | ||
</button> | ||
</div> | ||
@@ -132,8 +135,8 @@ ); | ||
// Show a message while the user waits to be redirected to the login page. | ||
const Redirecting = () => <div>Redirecting you to the login page...</div>; | ||
const PrivateRoute = () => <div>Private</div>; | ||
export default withAuthenticationRequired(PrivateRoute, Redirecting); | ||
export default withAuthenticationRequired(PrivateRoute, { | ||
// Show a message while the user waits to be redirected to the login page. | ||
onRedirecting: () => <div>Redirecting you to the login page...</div>, | ||
}); | ||
``` | ||
@@ -190,3 +193,3 @@ | ||
For a more detailed example see how to [create a `useApi` hook for accessing protected APIs with an access token](#4-create-a-useapi-hook-for-accessing-protected-apis-with-an-access-token). | ||
For a more detailed example see how to [create a `useApi` hook for accessing protected APIs with an access token](https://github.com/auth0/auth0-react/blob/master/EXAMPLES.md#4-create-a-useapi-hook-for-accessing-protected-apis-with-an-access-token). | ||
@@ -199,2 +202,3 @@ ## Contributing | ||
- [Auth0's code of conduct guidelines](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md) | ||
- [This repo's contribution guide](./CONTRIBUTING.md) | ||
@@ -205,2 +209,6 @@ ## Support + Feedback | ||
## Troubleshooting | ||
For information on how to solve common problems, check out the [Troubleshooting](./TROUBLESHOOTING.md) guide | ||
## Vulnerability Reporting | ||
@@ -207,0 +215,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
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
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1231326
3323
3
226
35
5