From 2402dc249d683a5b8d3dd39f89b6be15957cefd4 Mon Sep 17 00:00:00 2001 From: Lawrence Forooghian Date: Thu, 27 Apr 2023 11:20:00 -0300 Subject: [PATCH] Remove deprecated ability to pass AuthOptions.force property Part of #1197. --- src/common/lib/client/auth.ts | 13 ------------- src/common/lib/util/utils.ts | 9 --------- test/realtime/auth.test.js | 8 -------- 3 files changed, 30 deletions(-) diff --git a/src/common/lib/client/auth.ts b/src/common/lib/client/auth.ts index 4abf0f00d2..b97c32c3f3 100644 --- a/src/common/lib/client/auth.ts +++ b/src/common/lib/client/auth.ts @@ -284,19 +284,6 @@ class Auth { throw new ErrorInfo('Unable to update auth options with incompatible key', 40102, 401); } - if (_authOptions && 'force' in _authOptions) { - Logger.logAction( - Logger.LOG_ERROR, - 'Auth.authorize', - 'Deprecation warning: specifying {force: true} in authOptions is no longer necessary, authorize() now always gets a new token. Please remove this, as in version 1.0 and later, having a non-null authOptions will overwrite stored library authOptions, which may not be what you want' - ); - /* Emulate the old behaviour: if 'force' was the only member of authOptions, - * set it to null so it doesn't overwrite stored. TODO: remove in version 1.0 */ - if (Utils.isOnlyPropIn(_authOptions, 'force')) { - _authOptions = null; - } - } - this._forceNewToken( tokenParams as API.Types.TokenParams, _authOptions, diff --git a/src/common/lib/util/utils.ts b/src/common/lib/util/utils.ts index 28b8366274..573d9909a9 100644 --- a/src/common/lib/util/utils.ts +++ b/src/common/lib/util/utils.ts @@ -81,15 +81,6 @@ export function isEmpty(ob: Record | unknown[]): boolean { return true; } -export function isOnlyPropIn(ob: Record, property: string): boolean { - for (const prop in ob) { - if (prop !== property) { - return false; - } - } - return true; -} - /* * Determine whether or not an argument to an overloaded function is * undefined (missing) or null. diff --git a/test/realtime/auth.test.js b/test/realtime/auth.test.js index 26e97e1935..bfb6604154 100644 --- a/test/realtime/auth.test.js +++ b/test/realtime/auth.test.js @@ -972,14 +972,6 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async 'Check authorize completely replaces stored authOptions with passed in ones' ); - /* TODO remove for lib version 1.0 */ - realtime.auth.authorize(null, { authUrl: 'http://invalid' }); - realtime.auth.authorize(null, { force: true }); - expect(realtime.auth.authOptions.authUrl).to.equal( - 'http://invalid', - 'Check authorize does *not* replace stored authOptions when the only option is "force" in 0.9, for compatibility with 0.8' - ); - closeAndFinish(done, realtime); } catch (err) { closeAndFinish(done, realtime, err);