diff --git a/CHANGELOG.md b/CHANGELOG.md index 7807cb23..d04c8b9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Change Log +## [v2.2.0](https://github.com/auth0/react-native-auth0/tree/v2.2.0) (2020-01-30) + +[Full Changelog](https://github.com/auth0/react-native-auth0/compare/v2.1.1...v2.2.0) + +**Added** + +- Add passwordless endpoints [\#270](https://github.com/auth0/react-native-auth0/pull/270) ([lbalmaceda](https://github.com/lbalmaceda)) +- Handle missing kid (key id) on the JWKS [\#269](https://github.com/auth0/react-native-auth0/pull/269) ([lbalmaceda](https://github.com/lbalmaceda)) + +**Changed** + +- Refactor RSA verification: Replace jsrsasign with crypto-js [\#268](https://github.com/auth0/react-native-auth0/pull/268) ([lbalmaceda](https://github.com/lbalmaceda)) + ## [v2.1.1](https://github.com/auth0/react-native-auth0/tree/v2.1.1) (2020-01-10) [Full Changelog](https://github.com/auth0/react-native-auth0/compare/v2.1.0...v2.1.1) diff --git a/docs/Auth.html b/docs/Auth.html index aed9e6c5..8d34ffca 100644 --- a/docs/Auth.html +++ b/docs/Auth.html @@ -55,12 +55,40 @@ >exchange +
+ Finishes the Passworldess authentication with an email + connection +
+Name | + +Type | + +Description | +|||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
parameters |
+
+
+ Object
+ |
+
+
+ passwordless parameters + +
|
+
Promise
+ + Finishes the Passworldess authentication with an SMS connection +
+Name | + +Type | + +Description | +|||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
parameters |
+
+
+ Object
+ |
+
+
+ passwordless parameters + +
|
+
Promise
+ Starts the Passworldess flow with an email connection
+Name | + +Type | + +Description | +||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
parameters |
+
+
+ Object
+ |
+
+
+ passwordless parameters + +
|
+
Promise
+ Starts the Passworldess flow with an SMS connection
+Name | + +Type | + +Description | +||||||
---|---|---|---|---|---|---|---|---|
parameters |
+
+
+ Object
+ |
+
+
+ passwordless parameters + +
|
+
Promise
+ + Passwordless is a two-step authentication flow that makes use of + this type of connection. The Passwordless OTP grant + is required to be enabled in your Auth0 application beforehand. + Check + our guide + to learn how to enable it. +
++ To start the flow, you request a code to be sent to the user's email + or phone number. For email scenarios only, a link can be sent in + place of the code. +
+auth0.auth
+ .passwordlessWithEmail({
+ email: 'info@auth0.com',
+ send: 'link',
+ })
+ .then(console.log)
+ .catch(console.error);
+
+ or
+auth0.auth
+ .passwordlessWithSMS({
+ phoneNumber: '+5491159991000',
+ })
+ .then(console.log)
+ .catch(console.error);
+
+ + Then, in order to complete the authentication, you must send back + that received code value along with the email or phone number used: +
+auth0.auth
+ .loginWithEmail({
+ email: 'info@auth0.com',
+ code: '123456',
+ })
+ .then(console.log)
+ .catch(console.error);
+
+ or
+auth0.auth
+ .loginWithSMS({
+ phoneNumber: 'info@auth0.com',
+ code: '123456',
+ })
+ .then(console.log)
+ .catch(console.error);
auth0.auth
@@ -683,7 +765,7 @@ License
diff --git a/docs/index.js.html b/docs/index.js.html
index f21680ed..3cf91b22 100644
--- a/docs/index.js.html
+++ b/docs/index.js.html
@@ -55,12 +55,40 @@
>exchange
import Client from '../networking';
-import { apply } from '../utils/whitelist';
-import { toCamelCase } from '../utils/camel';
+import {apply} from '../utils/whitelist';
+import {toCamelCase} from '../utils/camel';
import AuthError from './authError';
import Auth0Error from './auth0Error';
@@ -172,7 +200,7 @@ src/auth/index.js
export default class Auth {
constructor(options = {}) {
this.client = new Client(options);
- const { clientId } = options;
+ const {clientId} = options;
if (!clientId) {
throw new Error('Missing clientId in parameters');
}
@@ -196,18 +224,18 @@ src/auth/index.js
const query = apply(
{
parameters: {
- redirectUri: { required: true, toName: 'redirect_uri' },
- responseType: { required: true, toName: 'response_type' },
- state: { required: true }
+ redirectUri: {required: true, toName: 'redirect_uri'},
+ responseType: {required: true, toName: 'response_type'},
+ state: {required: true},
},
- whitelist: false
+ whitelist: false,
},
- parameters
+ parameters,
);
return this.client.url(
'/authorize',
- { ...query, client_id: this.clientId },
- true
+ {...query, client_id: this.clientId},
+ true,
);
}
@@ -227,14 +255,14 @@ src/auth/index.js
const query = apply(
{
parameters: {
- federated: { required: false },
- clientId: { required: false, toName: 'client_id' },
- returnTo: { required: false }
- }
+ federated: {required: false},
+ clientId: {required: false, toName: 'client_id'},
+ returnTo: {required: false},
+ },
},
- parameters
+ parameters,
);
- return this.client.url('/v2/logout', { ...query }, true);
+ return this.client.url('/v2/logout', {...query}, true);
}
/**
@@ -253,18 +281,18 @@ src/auth/index.js
const payload = apply(
{
parameters: {
- code: { required: true },
- verifier: { required: true, toName: 'code_verifier' },
- redirectUri: { required: true, toName: 'redirect_uri' }
- }
+ code: {required: true},
+ verifier: {required: true, toName: 'code_verifier'},
+ redirectUri: {required: true, toName: 'redirect_uri'},
+ },
},
- parameters
+ parameters,
);
return this.client
.post('/oauth/token', {
...payload,
client_id: this.clientId,
- grant_type: 'authorization_code'
+ grant_type: 'authorization_code',
})
.then(responseHandler);
}
@@ -287,20 +315,20 @@ src/auth/index.js
const payload = apply(
{
parameters: {
- username: { required: true },
- password: { required: true },
- realm: { required: true },
- audience: { required: false },
- scope: { required: false }
- }
+ username: {required: true},
+ password: {required: true},
+ realm: {required: true},
+ audience: {required: false},
+ scope: {required: false},
+ },
},
- parameters
+ parameters,
);
return this.client
.post('/oauth/token', {
...payload,
client_id: this.clientId,
- grant_type: 'http://auth0.com/oauth/grant-type/password-realm'
+ grant_type: 'http://auth0.com/oauth/grant-type/password-realm',
})
.then(responseHandler);
}
@@ -320,17 +348,145 @@ src/auth/index.js
const payload = apply(
{
parameters: {
- refreshToken: { required: true, toName: 'refresh_token' },
- scope: { required: false }
- }
+ refreshToken: {required: true, toName: 'refresh_token'},
+ scope: {required: false},
+ },
},
- parameters
+ parameters,
);
return this.client
.post('/oauth/token', {
...payload,
client_id: this.clientId,
- grant_type: 'refresh_token'
+ grant_type: 'refresh_token',
+ })
+ .then(responseHandler);
+ }
+
+ /**
+ * Starts the Passworldess flow with an email connection
+ *
+ * @param {Object} parameters passwordless parameters
+ * @param {String} parameters.email the email to send the link/code to
+ * @param {String} parameters.send the passwordless strategy, either 'link' or 'code'
+ * @param {String} parameters.authParams optional parameters, used when strategy is 'linḱ'
+ * @returns {Promise}
+ *
+ * @memberof Auth
+ */
+ passwordlessWithEmail(parameters = {}) {
+ const payload = apply(
+ {
+ parameters: {
+ email: {required: true},
+ send: {required: false},
+ authParams: {required: false},
+ },
+ },
+ parameters,
+ );
+ return this.client
+ .post('/passwordless/start', {
+ ...payload,
+ connection: 'email',
+ client_id: this.clientId,
+ })
+ .then(responseHandler);
+ }
+
+ /**
+ * Starts the Passworldess flow with an SMS connection
+ *
+ * @param {Object} parameters passwordless parameters
+ * @param {String} parameters.phoneNumber the phone number to send the link/code to
+ * @returns {Promise}
+ *
+ * @memberof Auth
+ */
+ passwordlessWithSMS(parameters = {}) {
+ const payload = apply(
+ {
+ parameters: {
+ phoneNumber: {required: true, toName: 'phone_number'},
+ send: {required: false},
+ authParams: {required: false},
+ },
+ },
+ parameters,
+ );
+ return this.client
+ .post('/passwordless/start', {
+ ...payload,
+ connection: 'sms',
+ client_id: this.clientId,
+ })
+ .then(responseHandler);
+ }
+
+ /**
+ * Finishes the Passworldess authentication with an email connection
+ *
+ * @param {Object} parameters passwordless parameters
+ * @param {String} parameters.email the email where the link/code was received
+ * @param {String} parameters.code the code numeric value (OTP)
+ * @param {String} parameters.audience optional API audience to request
+ * @param {String} parameters.scope optional scopes to request
+ * @returns {Promise}
+ *
+ * @memberof Auth
+ */
+ loginWithEmail(parameters = {}) {
+ const payload = apply(
+ {
+ parameters: {
+ email: {required: true, toName: 'username'},
+ code: {required: true, toName: 'otp'},
+ audience: {required: false},
+ scope: {required: false},
+ },
+ },
+ parameters,
+ );
+ return this.client
+ .post('/oauth/token', {
+ ...payload,
+ client_id: this.clientId,
+ realm: 'email',
+ grant_type: 'http://auth0.com/oauth/grant-type/passwordless/otp',
+ })
+ .then(responseHandler);
+ }
+
+ /**
+ * Finishes the Passworldess authentication with an SMS connection
+ *
+ * @param {Object} parameters passwordless parameters
+ * @param {String} parameters.phoneNumber the phone number where the code was received
+ * @param {String} parameters.code the code numeric value (OTP)
+ * @param {String} parameters.audience optional API audience to request
+ * @param {String} parameters.scope optional scopes to request
+ * @returns {Promise}
+ *
+ * @memberof Auth
+ */
+ loginWithSMS(parameters = {}) {
+ const payload = apply(
+ {
+ parameters: {
+ phoneNumber: {required: true, toName: 'username'},
+ code: {required: true, toName: 'otp'},
+ audience: {required: false},
+ scope: {required: false},
+ },
+ },
+ parameters,
+ );
+ return this.client
+ .post('/oauth/token', {
+ ...payload,
+ client_id: this.clientId,
+ realm: 'sms',
+ grant_type: 'http://auth0.com/oauth/grant-type/passwordless/otp',
})
.then(responseHandler);
}
@@ -348,15 +504,15 @@ src/auth/index.js
const payload = apply(
{
parameters: {
- refreshToken: { required: true, toName: 'token' }
- }
+ refreshToken: {required: true, toName: 'token'},
+ },
},
- parameters
+ parameters,
);
return this.client
.post('/oauth/revoke', {
...payload,
- client_id: this.clientId
+ client_id: this.clientId,
})
.then(response => {
if (response.ok) {
@@ -379,13 +535,13 @@ src/auth/index.js
const payload = apply(
{
parameters: {
- token: { required: true }
- }
+ token: {required: true},
+ },
},
- parameters
+ parameters,
);
- const { baseUrl, telemetry } = this.client;
- const client = new Client({ baseUrl, telemetry, token: payload.token });
+ const {baseUrl, telemetry} = this.client;
+ const client = new Client({baseUrl, telemetry, token: payload.token});
const claims = [
'sub',
'name',
@@ -406,12 +562,12 @@ src/auth/index.js
'phone_number',
'phone_number_verified',
'address',
- 'updated_at'
+ 'updated_at',
];
return client
.get('/userinfo')
.then(response =>
- responseHandler(response, { attributes: claims, whitelist: true })
+ responseHandler(response, {attributes: claims, whitelist: true}),
);
}
@@ -429,16 +585,16 @@ src/auth/index.js
const payload = apply(
{
parameters: {
- email: { required: true },
- connection: { required: true }
- }
+ email: {required: true},
+ connection: {required: true},
+ },
},
- parameters
+ parameters,
);
return this.client
.post('/dbconnections/change_password', {
...payload,
- client_id: this.clientId
+ client_id: this.clientId,
})
.then(response => {
if (response.ok) {
@@ -465,20 +621,20 @@ src/auth/index.js
const payload = apply(
{
parameters: {
- email: { required: true },
- password: { required: true },
- connection: { required: true },
- username: { required: false },
- metadata: { required: false, toName: 'user_metadata' }
- }
+ email: {required: true},
+ password: {required: true},
+ connection: {required: true},
+ username: {required: false},
+ metadata: {required: false, toName: 'user_metadata'},
+ },
},
- parameters
+ parameters,
);
return this.client
.post('/dbconnections/signup', {
...payload,
- client_id: this.clientId
+ client_id: this.clientId,
})
.then(response => {
if (response.ok && response.json) {
@@ -497,7 +653,7 @@ src/auth/index.js
diff --git a/docs/src_management_users.js.html b/docs/src_management_users.js.html
index 19a38f75..a07df7be 100644
--- a/docs/src_management_users.js.html
+++ b/docs/src_management_users.js.html
@@ -55,12 +55,40 @@
>exchange