Skip to content

Commit

Permalink
Remove deprecated ability to pass AuthOptions.force property
Browse files Browse the repository at this point in the history
Part of #1197.
  • Loading branch information
lawrence-forooghian committed Apr 27, 2023
1 parent 742a981 commit 2402dc2
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 30 deletions.
13 changes: 0 additions & 13 deletions src/common/lib/client/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 0 additions & 9 deletions src/common/lib/util/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,6 @@ export function isEmpty(ob: Record<string, unknown> | unknown[]): boolean {
return true;
}

export function isOnlyPropIn(ob: Record<string, unknown>, 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.
Expand Down
8 changes: 0 additions & 8 deletions test/realtime/auth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2402dc2

Please sign in to comment.