From 3e0a3fd31c584e2bbcfab7a305512c2983c677d1 Mon Sep 17 00:00:00 2001 From: Luciano Balmaceda Date: Mon, 15 Jul 2019 14:20:17 -0300 Subject: [PATCH] 1.5.0 --- CHANGELOG.md | 12 ++++++++++ docs/Auth.html | 2 +- docs/Auth0.html | 2 +- docs/Auth0.module.exports.html | 2 +- docs/Users.html | 2 +- docs/WebAuth.html | 12 +++++----- docs/auth_index.js.html | 2 +- docs/global.html | 2 +- docs/index.html | 13 +++++++---- docs/index.js.html | 2 +- docs/management_users.js.html | 2 +- docs/webauth_index.js.html | 41 ++++++++++++++-------------------- networking/telemetry.js | 4 ++-- package.json | 2 +- 14 files changed, 55 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1500b974..baa1f98c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Change Log +## [v1.5.0](https://github.com/auth0/react-native-auth0/tree/v1.5.0) (2019-07-15) + +[Full Changelog](https://github.com/auth0/react-native-auth0/compare/v1.4.2...v1.5.0) + +**Changed** + +- Enable WebAuth Logout for Android & Fix iOS Logout. [\#223](https://github.com/auth0/react-native-auth0/pull/223) ([lbalmaceda](https://github.com/lbalmaceda)) + +**Fixed** + +- Fix error handling by using authentication error class [\#228](https://github.com/auth0/react-native-auth0/pull/228) ([lbalmaceda](https://github.com/lbalmaceda)) + ## [v1.4.2](https://github.com/auth0/react-native-auth0/tree/v1.4.2) (2019-04-24) [Full Changelog](https://github.com/auth0/react-native-auth0/compare/v1.4.2...v1.4.2) diff --git a/docs/Auth.html b/docs/Auth.html index a002fc7a..9d5288b4 100644 --- a/docs/Auth.html +++ b/docs/Auth.html @@ -2638,7 +2638,7 @@
Returns:

diff --git a/docs/Auth0.html b/docs/Auth0.html index 20052d85..971e6d25 100644 --- a/docs/Auth0.html +++ b/docs/Auth0.html @@ -172,7 +172,7 @@

Classes


diff --git a/docs/Auth0.module.exports.html b/docs/Auth0.module.exports.html index 870c0ef2..1896c71d 100644 --- a/docs/Auth0.module.exports.html +++ b/docs/Auth0.module.exports.html @@ -296,7 +296,7 @@
Parameters:

diff --git a/docs/Users.html b/docs/Users.html index 680317d4..8749d9be 100644 --- a/docs/Users.html +++ b/docs/Users.html @@ -630,7 +630,7 @@
Returns:

diff --git a/docs/WebAuth.html b/docs/WebAuth.html index 421909c1..95c31a09 100644 --- a/docs/WebAuth.html +++ b/docs/WebAuth.html @@ -101,7 +101,7 @@

new WebAuthSource:
@@ -212,7 +212,7 @@

(static) au
Source:
@@ -546,8 +546,8 @@

(static) -

Removes Auth0 session and optionally remove the Identity Provider session. - In iOS it will use SFSafariViewController

+

Removes Auth0 session and optionally remove the Identity Provider session.

+

In iOS it will use SFSafariViewController and in Android Chrome Custom Tabs.

@@ -583,7 +583,7 @@

(static) Source:
@@ -778,7 +778,7 @@

Returns:

- Generated by JSDoc 3.5.5 on Wed Apr 24 2019 16:21:16 GMT-0300 (-03) using the Minami theme. + Generated by JSDoc 3.5.5 on Mon Jul 15 2019 14:20:17 GMT-0300 (Argentina Standard Time) using the Minami theme.
diff --git a/docs/auth_index.js.html b/docs/auth_index.js.html index 26c06f84..0ddeeb6f 100644 --- a/docs/auth_index.js.html +++ b/docs/auth_index.js.html @@ -390,7 +390,7 @@

auth/index.js


- Generated by JSDoc 3.5.5 on Wed Apr 24 2019 16:21:16 GMT-0300 (-03) using the Minami theme. + Generated by JSDoc 3.5.5 on Mon Jul 15 2019 14:20:17 GMT-0300 (Argentina Standard Time) using the Minami theme.
diff --git a/docs/global.html b/docs/global.html index 40e4a085..1137f5ea 100644 --- a/docs/global.html +++ b/docs/global.html @@ -285,7 +285,7 @@
Returns:

- Generated by JSDoc 3.5.5 on Wed Apr 24 2019 16:21:16 GMT-0300 (-03) using the Minami theme. + Generated by JSDoc 3.5.5 on Mon Jul 15 2019 14:20:17 GMT-0300 (Argentina Standard Time) using the Minami theme.
diff --git a/docs/index.html b/docs/index.html index caaea1b6..15168870 100644 --- a/docs/index.html +++ b/docs/index.html @@ -59,7 +59,7 @@

Installation

Install react-native-auth0 using npm install react-native-auth0 --save

Or via yarn

yarn add react-native-auth0

then you need to link the native module in react-native-auth0

react-native link react-native-auth0

Configuration

-

This section is for those that want to use WebAuth, if you dont need it just ignore this section.

+

This section is for those that want to use Web Authentication, if you dont need it just ignore this section.

Android

In the file android/app/src/main/AndroidManifest.xml you must make sure the MainActivity of the app has a launchMode value of singleTask and that it has the following intent filter:

<intent-filter>
@@ -120,6 +120,8 @@ 

iOS

Inside the ios folder find the file AppDelegat </array>

The <string> value should be the literal value of the Bundle Identifier with no $ variables, for example: samples.auth0.com.

The value org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) is the default for apps created with React Native CLI, you may have a different value.

+
+

For more info please read react native docs

Callback URL(s)

Callback URLs are the URLs that Auth0 invokes after the authentication process. Auth0 routes your application back to this URL and appends additional parameters to it, including a token. Since callback URLs can be manipulated, you will need to add this URL to your Application's Allowed Callback URLs for security. This will enable Auth0 to recognize these URLs as valid. If omitted, authentication will not be successful.

@@ -129,14 +131,17 @@

Callback URL(s)

Callback URLs are the URLs that Auth0 invokes after t

Go to the Auth0 Dashboard, select your application and make sure that Allowed Callback URLs contains the following:

iOS

{YOUR_BUNDLE_IDENTIFIER}://${YOUR_AUTH0_DOMAIN}/ios/{YOUR_BUNDLE_IDENTIFIER}/callback

Android

{YOUR_APP_PACKAGE_NAME}://{YOUR_AUTH0_DOMAIN}/android/{YOUR_APP_PACKAGE_NAME}/callback

Usage

import Auth0 from 'react-native-auth0';
 
-const auth0 = new Auth0({ domain: '{YOUR_AUTH0_DOMAIN}', clientId: '{YOUR_CLIENT_ID}' });

WebAuth

auth0
+const auth0 = new Auth0({ domain: '{YOUR_AUTH0_DOMAIN}', clientId: '{YOUR_CLIENT_ID}' });

Web Authentication

Log in

auth0
     .webAuth
     .authorize({scope: 'openid email', audience: 'https://{YOUR_AUTH0_DOMAIN}/userinfo'})
     .then(credentials => console.log(credentials))
     .catch(error => console.log(error));

This snippet sets the audience to ensure OIDC compliant responses, this can also be achieved by enabling the OIDC Conformant switch in your Auth0 dashboard under Application / Settings / Advanced OAuth. For more information please check this documentation.

-

Authentication API

Important: Database Connection Authentication

Since June 2017 new Clients no longer have the Password Grant Type* enabled by default. +

Log out

auth0
+    .webAuth
+    .clearSession()
+    .catch(error => console.log(error));

Authentication API

Important: Database Connection Authentication

Since June 2017 new Clients no longer have the Password Grant Type* enabled by default. If you are accessing a Database Connection using passwordRealm then you will need to enable the Password Grant Type, please follow this guide.

Login with Password Realm Grant

auth0
     .auth
@@ -192,7 +197,7 @@ 

License

This project is licensed under the MIT license. See the

- Generated by JSDoc 3.5.5 on Wed Apr 24 2019 16:21:16 GMT-0300 (-03) using the Minami theme. + Generated by JSDoc 3.5.5 on Mon Jul 15 2019 14:20:17 GMT-0300 (Argentina Standard Time) using the Minami theme.
diff --git a/docs/index.js.html b/docs/index.js.html index a1ea4c41..a59a422b 100644 --- a/docs/index.js.html +++ b/docs/index.js.html @@ -88,7 +88,7 @@

index.js


- Generated by JSDoc 3.5.5 on Wed Apr 24 2019 16:21:16 GMT-0300 (-03) using the Minami theme. + Generated by JSDoc 3.5.5 on Mon Jul 15 2019 14:20:17 GMT-0300 (Argentina Standard Time) using the Minami theme.
diff --git a/docs/management_users.js.html b/docs/management_users.js.html index 27ffc21f..78f8ef5b 100644 --- a/docs/management_users.js.html +++ b/docs/management_users.js.html @@ -155,7 +155,7 @@

management/users.js


- Generated by JSDoc 3.5.5 on Wed Apr 24 2019 16:21:16 GMT-0300 (-03) using the Minami theme. + Generated by JSDoc 3.5.5 on Mon Jul 15 2019 14:20:17 GMT-0300 (Argentina Standard Time) using the Minami theme.
diff --git a/docs/webauth_index.js.html b/docs/webauth_index.js.html index 6c0e1fe1..e2f88f5c 100644 --- a/docs/webauth_index.js.html +++ b/docs/webauth_index.js.html @@ -43,11 +43,17 @@

webauth/index.js

import { NativeModules, Platform } from 'react-native'; import url from 'url'; -import Auth0Error from '../auth/auth0Error'; import AuthError from '../auth/authError'; const { A0Auth0 } = NativeModules; +const callbackUri = domain => { + const bundleIdentifier = A0Auth0.bundleIdentifier; + return `${bundleIdentifier.toLowerCase()}://${domain}/${ + Platform.OS + }/${bundleIdentifier}/callback`; +}; + /** * Helper to perform Auth against Auth0 hosted login page * @@ -89,10 +95,7 @@

webauth/index.js

authorize(options = {}) { const { clientId, domain, client, agent } = this; return agent.newTransaction().then(({ state, verifier, ...defaults }) => { - const bundleIdentifier = A0Auth0.bundleIdentifier; - const redirectUri = `${bundleIdentifier.toLowerCase()}://${domain}/${ - Platform.OS - }/${bundleIdentifier}/callback`; + const redirectUri = callbackUri(domain); const expectedState = options.state || state; let query = { ...defaults, @@ -100,7 +103,7 @@

webauth/index.js

responseType: 'code', redirectUri, state: expectedState, - ...options, + ...options }; const authorizeUrl = this.client.authorizeUrl(query); return agent.show(authorizeUrl).then(redirectUrl => { @@ -116,7 +119,7 @@

webauth/index.js

const query = url.parse(redirectUrl, true).query; const { code, state: resultState, error } = query; if (error) { - throw new Auth0Error({ json: query, status: 0 }); + throw new AuthError({ json: query, status: 0 }); } if (resultState !== expectedState) { throw new AuthError({ @@ -134,7 +137,8 @@

webauth/index.js

/** * Removes Auth0 session and optionally remove the Identity Provider session. - * In iOS it will use `SFSafariViewController` + * + * In iOS it will use `SFSafariViewController` and in Android Chrome Custom Tabs. * * @param {Object} parameters parameters to send * @param {Bool} [parameters.federated] Optionally remove the IdP session. @@ -144,21 +148,10 @@

webauth/index.js

* @memberof WebAuth */ clearSession(options = {}) { - if (Platform.OS !== 'ios') { - return Promise.reject( - new AuthError({ - json: { - error: 'a0.platform.not_available', - error_description: `Cannot perform operation in platform ${ - Platform.OS - }` - }, - status: 0 - }) - ); - } - const { client, agent } = this; - const federated = options.federated || false; + const { client, agent, domain, clientId } = this; + options.clientId = clientId; + options.returnTo = callbackUri(domain); + options.federated = options.federated || false; const logoutUrl = client.logoutUrl(options); return agent.show(logoutUrl, true); } @@ -175,7 +168,7 @@

webauth/index.js


- Generated by JSDoc 3.5.5 on Wed Apr 24 2019 16:21:16 GMT-0300 (-03) using the Minami theme. + Generated by JSDoc 3.5.5 on Mon Jul 15 2019 14:20:17 GMT-0300 (Argentina Standard Time) using the Minami theme.
diff --git a/networking/telemetry.js b/networking/telemetry.js index afb243a9..12776c67 100644 --- a/networking/telemetry.js +++ b/networking/telemetry.js @@ -1,5 +1,5 @@ -// Generated file by lbalmaceda on Wed Apr 24 2019 16:21:16 GMT-0300 (-03); +// Generated file by lbalmaceda on Mon Jul 15 2019 14:20:17 GMT-0300 (Argentina Standard Time); module.exports = { name: 'react-native-auth0', - version: '1.4.2' + version: '1.5.0' }; diff --git a/package.json b/package.json index 35e08c7b..abbbec8b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-auth0", - "version": "1.4.2", + "version": "1.5.0", "description": "React Native toolkit for Auth0 API", "main": "index.js", "scripts": {