diff --git a/addon/utils/cognito-storage.js b/addon/utils/cognito-storage.js deleted file mode 100644 index ffed826a..00000000 --- a/addon/utils/cognito-storage.js +++ /dev/null @@ -1,74 +0,0 @@ -import { deprecate } from '@ember/debug'; - -/** - * @private - * CognitoStorage is used to wrap the Cognito SDK's use of local storage. - * Rather than directly writing to localStorage, this is captured in memory and then - * persisted in ember-simple-auth's "authenticated" data. - * Effectively, this is a wrapper to ember-simple-auth's authenticated data designed - * to look like window.localStorage - * It's also based on https://github.com/aws/amazon-cognito-identity-js/blob/master/src/StorageHelper.js - * but converted to be a true non-static object. - */ -export default class CognitoStorage { - constructor(data = {}) { - deprecate('The CognitoStorage object has been deprecated.', false, { - for: 'ember-cognito', - id: 'ember-cognito-storage', - since: '0.12.0', - until: '1.0.0', - }); - this.data = data; - } - - getData() { - return this.data; - } - - /** - * @public - * This is used to set a specific item in storage - * @param {string} key - the key for the item - * @param {object} value - the value - * @returns {string} value that was set - */ - setItem(key, value) { - this.data[key] = value; - return this.data[key]; - } - - /** - * @public - * This is used to get a specific key from storage - * @param {string} key - the key for the item - * This is used to clear the storage - * @returns {string} the data item - */ - getItem(key) { - return Object.prototype.hasOwnProperty.call(this.data, key) - ? this.data[key] - : undefined; - } - - /** - * @public - * This is used to remove an item from storage - * @param {string} key - the key being set - * @returns {string} value - value that was deleted - */ - removeItem(key) { - let value = this.data[key]; - delete this.data[key]; - return value; - } - - /** - * @public - * This is used to clear the storage - * @returns {string} nothing - */ - clear() { - this.data = {}; - return this.data; - } -} diff --git a/addon/utils/cognito-user.js b/addon/utils/cognito-user.js index cd235292..4c88312b 100644 --- a/addon/utils/cognito-user.js +++ b/addon/utils/cognito-user.js @@ -1,7 +1,6 @@ import { Promise } from 'rsvp'; import EmberObject, { computed } from '@ember/object'; import { readOnly } from '@ember/object/computed'; -import { deprecate } from '@ember/debug'; import { normalizeAttributes } from './utils'; // @@ -35,41 +34,6 @@ export default class CognitoUser extends EmberObject { return auth.changePassword(user, oldPassword, newPassword); } - confirmPassword(verificationCode, newPassword) { - deprecate( - 'This functionality has moved to forgotPasswordSubmit() on the Cognito service.', - false, - { - for: 'ember-cognito', - id: 'ember-cognito-confirm-password', - since: '0.12.0', - until: '1.0.0', - } - ); - - const { auth, username } = this; - return auth.forgotPasswordSubmit(username, verificationCode, newPassword); - } - - confirmRegistration(confirmationCode, forceAliasCreation) { - deprecate( - 'This functionality has moved to confirmSignUp() on the Cognito service.', - false, - { - for: 'ember-cognito', - id: 'ember-cognito-confirm-registration', - since: '0.12.0', - until: '1.0.0', - } - ); - - const { auth, username } = this; - const options = forceAliasCreation - ? { forceAliasCreation: true } - : undefined; - return auth.confirmSignUp(username, confirmationCode, options); - } - deleteAttributes(attributeList) { return this._callback('deleteAttributes', attributeList); } @@ -78,22 +42,6 @@ export default class CognitoUser extends EmberObject { return this._callback('deleteUser'); } - forgotPassword() { - deprecate( - 'This functionality has moved to forgotPassword() on the Cognito service.', - false, - { - for: 'ember-cognito', - id: 'ember-cognito-forgot-password', - since: '0.12.0', - until: '1.0.0', - } - ); - - const { auth, username } = this; - return auth.forgotPassword(username); - } - getAttributeVerificationCode(attributeName) { const { auth, user } = this; return auth.verifyUserAttribute(user, attributeName); @@ -114,22 +62,6 @@ export default class CognitoUser extends EmberObject { return normalizeAttributes(result, false); } - resendConfirmationCode() { - deprecate( - 'This functionality has moved to resendSignUp() on the Cognito service.', - false, - { - for: 'ember-cognito', - id: 'ember-cognito-resend-confirmation-code', - since: '0.12.0', - until: '1.0.0', - } - ); - - const { auth, username } = this; - return auth.resendSignUp(username); - } - signOut() { return this.auth.signOut(); } @@ -155,18 +87,4 @@ export default class CognitoUser extends EmberObject { let payload = session.getIdToken().payload || {}; return payload['cognito:groups'] || []; } - - getStorageData() { - deprecate( - 'getStorageData() no longer used, and always returns an empty object.', - false, - { - for: 'ember-cognito', - id: 'ember-cognito-get-storage-data', - since: '0.12.0', - until: '1.0.0', - } - ); - return {}; - } } diff --git a/tests/unit/utils/cognito-storage-test.js b/tests/unit/utils/cognito-storage-test.js deleted file mode 100644 index 449ecdb4..00000000 --- a/tests/unit/utils/cognito-storage-test.js +++ /dev/null @@ -1,21 +0,0 @@ -import CognitoStorage from 'dummy/utils/cognito-storage'; -import { module, test } from 'qunit'; - -module('Unit | Utility | cognito storage', function () { - test('it works', function (assert) { - let storage = new CognitoStorage(); - - let key = 'Cognito.ClientId.idToken'; - assert.strictEqual(storage.getItem(key), undefined); - - storage.setItem(key, 'xyxyxyx'); - assert.strictEqual(storage.getItem(key), 'xyxyxyx'); - assert.deepEqual(storage.getData(), { - 'Cognito.ClientId.idToken': 'xyxyxyx', - }); - - let result = storage.removeItem(key); - assert.strictEqual(result, 'xyxyxyx'); - assert.strictEqual(storage.getItem(key), undefined); - }); -}); diff --git a/tests/unit/utils/cognito-user-test.js b/tests/unit/utils/cognito-user-test.js index df51ed4c..80e36a3b 100644 --- a/tests/unit/utils/cognito-user-test.js +++ b/tests/unit/utils/cognito-user-test.js @@ -34,36 +34,6 @@ module('Unit | Utility | cognito user', function (hooks) { await user.changePassword('oldpass', 'newpass'); }); - test('confirmPassword', async function (assert) { - assert.expect(3); - - const auth = MockAuth.extend({ - forgotPasswordSubmit(username, verificationCode, newPassword) { - assert.strictEqual(username, 'testuser'); - assert.strictEqual(verificationCode, '1234'); - assert.strictEqual(newPassword, 'newpass'); - }, - }).create(); - - const user = CognitoUser.create({ auth, user: newUser('testuser') }); - await user.confirmPassword('1234', 'newpass'); - }); - - test('confirmRegistration', async function (assert) { - assert.expect(3); - - const auth = MockAuth.extend({ - confirmSignUp(username, confirmationCode, options) { - assert.strictEqual(username, 'testuser'); - assert.strictEqual(confirmationCode, '1234'); - assert.deepEqual(options, { forceAliasCreation: true }); - }, - }).create(); - - const user = CognitoUser.create({ auth, user: newUser('testuser') }); - await user.confirmRegistration('1234', true); - }); - test('deleteAttributes', async function (assert) { assert.expect(1); @@ -88,19 +58,6 @@ module('Unit | Utility | cognito user', function (hooks) { assert.strictEqual(text, 'SUCCESS'); }); - test('forgotPassword', async function (assert) { - assert.expect(1); - - const auth = MockAuth.extend({ - forgotPassword(username) { - assert.strictEqual(username, 'testuser'); - }, - }).create(); - - const user = CognitoUser.create({ auth, user: newUser('testuser') }); - await user.forgotPassword(); - }); - test('getAttributeVerificationCode', async function (assert) { assert.expect(2); @@ -182,19 +139,6 @@ module('Unit | Utility | cognito user', function (hooks) { }); }); - test('resendConformationCode', async function (assert) { - assert.expect(1); - - const auth = MockAuth.extend({ - resendSignUp(username) { - assert.strictEqual(username, 'testuser'); - }, - }).create(); - - const user = CognitoUser.create({ auth, user: newUser('testuser') }); - await user.resendConfirmationCode(); - }); - test('updateAttributes', async function (assert) { assert.expect(4);