Skip to content

Commit

Permalink
remove deprecated userAgent from oktaAuth instance
Browse files Browse the repository at this point in the history
OKTA-419417
<<<Jenkins Check-In of Tested SHA: 6e7feb9 for eng_productivity_ci_bot_okta@okta.com>>>
Artifact: okta-auth-js
Files changed count: 8
PR Link: "#1050"
  • Loading branch information
shuowu authored and eng-prod-CI-bot-okta committed Jan 7, 2022
1 parent d053eee commit 71f18af
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 130 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- [#1003](https://github.com/okta/okta-auth-js/pull/1003) Supports generic UserClaims type. Custom claims should be extended by typescript generics, like `UserClaims<{ groups: string[]; }>`
- [#1049](https://github.com/okta/okta-auth-js/pull/1049) Bump minimum supported node version to 12.20
- [#1050](https://github.com/okta/okta-auth-js/pull/1050) Removes `userAgent` field from oktaAuth instance

## 5.10.0

Expand Down
11 changes: 1 addition & 10 deletions lib/OktaAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/* SDK_VERSION is defined in webpack config */
/* global window, SDK_VERSION */
/* global window */

import {
DEFAULT_MAX_CLOCK_SKEW,
Expand Down Expand Up @@ -92,7 +91,6 @@ import {
EmailVerifyCallbackResponse,
parseEmailVerifyCallback
} from './util';
import { getUserAgent } from './builderUtil';
import { TokenManager } from './TokenManager';
import { get, setRequestHeader } from './http';
import PromiseQueue from './PromiseQueue';
Expand Down Expand Up @@ -126,10 +124,6 @@ class OktaAuth implements SDKInterface, SigninAPI, SignoutAPI {
transactionManager: TransactionManager;
tx: TransactionAPI;
idx: IdxAPI;
// keep this field to compatible with released downstream SDK versions
// TODO: remove in version 6
// JIRA: https://oktainc.atlassian.net/browse/OKTA-419417
userAgent: string;
session: SessionAPI;
pkce: PkceAPI;
static features: FeaturesAPI;
Expand Down Expand Up @@ -181,9 +175,6 @@ class OktaAuth implements SDKInterface, SigninAPI, SignoutAPI {
this.options = Object.assign(this.options, {
redirectUri: toAbsoluteUrl(args.redirectUri, window.location.origin), // allow relative URIs
});
this.userAgent = getUserAgent(args, `okta-auth-js/${SDK_VERSION}`);
} else {
this.userAgent = getUserAgent(args, `okta-auth-js-server/${SDK_VERSION}`);
}

// Digital clocks will drift over time, so the server
Expand Down
17 changes: 1 addition & 16 deletions lib/builderUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,6 @@ function assertValidConfig(args: OktaAuthOptions) {
}
}

function getUserAgent(args: OktaAuthOptions, sdkValue: string): string {
var userAgent = args.userAgent || {};

if (userAgent.value) {
return userAgent.value;
}

if (userAgent.template) {
return userAgent.template.replace('$OKTA_AUTH_JS', sdkValue);
}

return sdkValue;
}

export {
assertValidConfig,
getUserAgent
assertValidConfig
};
6 changes: 1 addition & 5 deletions lib/types/OktaAuthOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ export interface TokenManagerOptions {
syncStorage?: boolean;
_storageEventDelay?: number;
}
export interface CustomUserAgent {
template?: string;
value?: string;
}

export interface CustomUrls {
issuer?: string;
authorizeUrl?: string;
Expand All @@ -57,7 +54,6 @@ export interface OktaAuthOptions extends CustomUrls {
storageUtil?: StorageUtil;
ajaxRequest?: object;
httpRequestClient?: HttpRequestClient;
userAgent?: CustomUserAgent;
cookies?: CookieOptions;
transformErrorXHR?: (xhr: object) => any;
headers?: object;
Expand Down
1 change: 0 additions & 1 deletion lib/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { IntrospectOptions } from '../idx/introspect';
import { IdxResponse } from '../idx/types/idx-js';
export interface OktaAuth {
options: OktaAuthOptions;
userAgent: string;
getIssuerOrigin(): string;
getOriginalUri(): string;

Expand Down
12 changes: 0 additions & 12 deletions test/spec/OktaAuth/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,6 @@ describe('OktaAuth (browser)', function() {
auth = new OktaAuth({ issuer, pkce: false });
});

// TODO: remove in 6.0
describe('userAgent', () => {
let sdkVersion;
beforeEach(async () => {
sdkVersion = (await import('../../../package.json')).version;
});

it('initials userAgent field', () => {
expect(auth.userAgent).toBe(`okta-auth-js/${sdkVersion}`);
});
});

describe('options', function() {
describe('cookies', () => {

Expand Down
20 changes: 0 additions & 20 deletions test/spec/OktaAuth/constructor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ jest.mock('../../../lib/features', () => {
};
});

const mocked = {
features: require('../../../lib/features')
};

describe('OktaAuth (constructor)', () => {
const apiUrlOptions = [
'issuer',
Expand Down Expand Up @@ -153,20 +149,4 @@ describe('OktaAuth (constructor)', () => {
});
});

// TODO: remove in 6.0
describe('userAgent', () => {
let sdkVersion;
beforeEach(async () => {
sdkVersion = (await import('../../../package.json')).version;
});

// browser env is tested in "./browser.ts"
it('initials userAgent field for node env', () => {
jest.spyOn(mocked.features, 'isBrowser').mockReturnValue(false);
const config = { issuer: 'http://fake' };
const oa = new OktaAuth(config);
expect(oa.userAgent).toBe(`okta-auth-js-server/${sdkVersion}`);
});
});

});
66 changes: 0 additions & 66 deletions test/spec/builderUtil.js

This file was deleted.

0 comments on commit 71f18af

Please sign in to comment.