Skip to content

Commit

Permalink
refactor: idx methods now use auth-js http client
Browse files Browse the repository at this point in the history
OKTA-417473
<<<Jenkins Check-In of Tested SHA: 4baca3d for eng_productivity_ci_bot_okta@okta.com>>>
Artifact: okta-auth-js
Files changed count: 76
PR Link: "#1145"
  • Loading branch information
jaredperreault-okta authored and eng-prod-CI-bot-okta committed Mar 25, 2022
1 parent 546b09b commit 513646f
Show file tree
Hide file tree
Showing 52 changed files with 838 additions and 1,527 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## 6.4

### Fixes

- [#1145](https://github.com/okta/okta-auth-js/pull/1145)
- IDX: form field-level messages are now passed through via idxState
- Type Fixes:
- IdxContent: `user` property now optional
- Input: added missing `key` property

### Other

- [#1145](https://github.com/okta/okta-auth-js/pull/1145)
- refactor: IDX methods now use auth-js http client
- refactor: idx-js methods have been refactored to idxState

## 6.3.0

### Features
Expand Down
3 changes: 0 additions & 3 deletions lib/OktaAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ import {
parseEmailVerifyCallback,
isEmailVerifyCallbackError
} from './idx';
import { createGlobalRequestInterceptor, setGlobalRequestInterceptor } from './idx/headers';
import { OktaUserAgent } from './OktaUserAgent';
import { parseOAuthResponseFromUrl } from './oidc/parseFromUrl';
import {
Expand Down Expand Up @@ -336,8 +335,6 @@ class OktaAuth implements OktaAuthInterface, SigninAPI, SignoutAPI {
unlockAccount: unlockAccount.bind(null, this),
};

setGlobalRequestInterceptor(createGlobalRequestInterceptor(this)); // to pass custom headers to IDX endpoints

// HTTP
this.http = {
setRequestHeader: setRequestHeader.bind(null, this)
Expand Down
17 changes: 14 additions & 3 deletions lib/fetch/fetchRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import crossFetch from 'cross-fetch';
import { FetchOptions, HttpResponse } from '../types';

// content-type = application/json OR application/ion+json
const appJsonContentTypeRegex = /application\/\w*\+?json/;

function readData(response: Response): Promise<object | string> {
if (response.headers.get('Content-Type') &&
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
Expand Down Expand Up @@ -54,10 +57,18 @@ function fetchRequest(method: string, url: string, args: FetchOptions) {
var headers = args.headers || {};
var contentType = (headers['Content-Type'] || headers['content-type'] || '');

// JSON encode body (if appropriate)
if (contentType === 'application/json' && body && typeof body !== 'string') {
body = JSON.stringify(body);
if (body && typeof body !== 'string') {
// JSON encode body (if appropriate)
if (appJsonContentTypeRegex.test(contentType)) {
body = JSON.stringify(body);
}
else if (contentType === 'application/x-www-form-urlencoded') {
body = Object.entries(body)
.map( ([param, value]) => `${param}=${encodeURIComponent(value)}` )
.join('&');
}
}

var fetch = global.fetch || crossFetch;
var fetchPromise = fetch(url, {
method: method,
Expand Down
46 changes: 0 additions & 46 deletions lib/idx/headers.ts

This file was deleted.

77 changes: 0 additions & 77 deletions lib/idx/idx-js/client.ts

This file was deleted.

29 changes: 0 additions & 29 deletions lib/idx/idx-js/index.ts

This file was deleted.

63 changes: 0 additions & 63 deletions lib/idx/idx-js/interact.ts

This file was deleted.

51 changes: 0 additions & 51 deletions lib/idx/idx-js/introspect.ts

This file was deleted.

32 changes: 0 additions & 32 deletions lib/idx/idx-js/parsers.ts

This file was deleted.

Loading

0 comments on commit 513646f

Please sign in to comment.