From 0d54f776014fa3c57fb70c30024e65fcac35cdff Mon Sep 17 00:00:00 2001 From: Max Ulyanov Date: Thu, 27 Jan 2022 10:43:54 +0400 Subject: [PATCH] signIn method should provide using audience prop in userData --- src/auth/PasswordlessAuthenticator.js | 1 + test/auth/passwordless.tests.js | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/auth/PasswordlessAuthenticator.js b/src/auth/PasswordlessAuthenticator.js index c380e08ff..44c849f09 100644 --- a/src/auth/PasswordlessAuthenticator.js +++ b/src/auth/PasswordlessAuthenticator.js @@ -104,6 +104,7 @@ class PasswordlessAuthenticator { * @param {object} userData User credentials object. * @param {string} userData.username The user's phone number if realm=sms, or the user's email if realm=email * @param {string} userData.otp The user's verification code. Required + * @param {string} [userData.audience] API Identifier of the API for which you want to get an Access Token. * @param {string} [userData.realm=sms] Realm string: "sms" or "email". * @param {string} [userData.password] [DEPRECATED] Password required if using legacy /oauth/ro endpoint * @param {string} [userData.connection=sms] [DEPRECATED] Connection string: "sms" or "email". diff --git a/test/auth/passwordless.tests.js b/test/auth/passwordless.tests.js index 935fe0e3d..303248502 100644 --- a/test/auth/passwordless.tests.js +++ b/test/auth/passwordless.tests.js @@ -465,6 +465,29 @@ describe('PasswordlessAuthenticator', () => { }) .catch(done); }); + + it('should make it possible to use audience property', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(path, (body) => body.audience === 'TEST_AUDIENCE') + .reply(200); + + this.authenticator + .signIn( + { + ...userData, + audience: 'TEST_AUDIENCE', + }, + options + ) + .then(() => { + expect(request.isDone()).to.be.true; + + done(); + }) + .catch(done); + }); }); });