Skip to content

Commit

Permalink
sets useInteractionCodeFlow to true in spa samples and test app
Browse files Browse the repository at this point in the history
adds dynamic signin form to spa samples
sets IdxFeature enum to use human readable strings

export all idx, rename old introspect to introspectAuthn

OKTA-458192
<<<Jenkins Check-In of Tested SHA: b419bd2 for eng_productivity_ci_bot_okta@okta.com>>>
Artifact: okta-auth-js
Files changed count: 51
PR Link: "#1062"
  • Loading branch information
aarongranick-okta authored and eng-prod-CI-bot-okta committed Jan 19, 2022
1 parent 0c8ed5c commit 390189f
Show file tree
Hide file tree
Showing 39 changed files with 679 additions and 361 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
- [#1066](https://github.com/okta/okta-auth-js/pull/1066) Extends type `CookieOptions` from `js-cookie` v3
- Uses enums for `CookieOptions.sameSite`
- Removes type `SetCookieOptions`
- [#1062](https://github.com/okta/okta-auth-js/pull/1062)
- Authn method `introspect` is renamed to `introspectAuthn` (still callable as `tx.introspect`)
- `IdxFeature` enum is now defined as strings instead of numbers

### Features

Expand All @@ -28,6 +31,9 @@
- `autoRemediate`. If false, there will be no attempt to satisfy remediations even if values have been passed.
- TransactionManager supports new option:
- `saveLastResponse`. If false, IDX responses will not be cached.
- [#1062](https://github.com/okta/okta-auth-js/pull/1062)
- All IDX methods are exported.
- `useInteractionCodeFlow` defaults to `true` for sample and test apps.

## 5.10.1

Expand Down
13 changes: 7 additions & 6 deletions lib/OktaAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import {
transactionStatus,
resumeTransaction,
transactionExists,
introspect,
introspectAuthn,
postToTransaction,
AuthTransaction
} from './tx';
Expand Down Expand Up @@ -101,7 +101,7 @@ import TransactionManager from './TransactionManager';
import { buildOptions } from './options';
import {
interact,
introspect as introspectV2,
introspect,
authenticate,
cancel,
poll,
Expand Down Expand Up @@ -168,7 +168,7 @@ class OktaAuth implements SDKInterface, SigninAPI, SignoutAPI {
return storage.get(name);
}
}),
introspect: introspect.bind(null, this)
introspect: introspectAuthn.bind(null, this)
};

this.pkce = {
Expand Down Expand Up @@ -285,7 +285,7 @@ class OktaAuth implements SDKInterface, SigninAPI, SignoutAPI {
const boundStartTransaction = startTransaction.bind(null, this);
this.idx = {
interact: interact.bind(null, this),
introspect: introspectV2.bind(null, this),
introspect: introspect.bind(null, this),
authenticate: authenticate.bind(null, this),
register: register.bind(null, this),
start: boundStartTransaction,
Expand Down Expand Up @@ -357,12 +357,13 @@ class OktaAuth implements SDKInterface, SigninAPI, SignoutAPI {
this.options.headers = Object.assign({}, this.options.headers, headers);
}


// Authn V1
async signIn(opts: SigninOptions): Promise<AuthTransaction> {
// TODO: support interaction code flow
// Authn V1 flow
return this.signInWithCredentials(opts as SigninWithCredentialsOptions);
}

// Authn V1
async signInWithCredentials(opts: SigninWithCredentialsOptions): Promise<AuthTransaction> {
opts = clone(opts || {});
const _postToTransaction = (options?) => {
Expand Down
6 changes: 3 additions & 3 deletions lib/idx/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ export type NextStep = {
}

export enum IdxFeature {
PASSWORD_RECOVERY,
REGISTRATION,
SOCIAL_IDP,
PASSWORD_RECOVERY = 'recover-password',
REGISTRATION = 'enroll-profile',
SOCIAL_IDP = 'redirect-idp',
}

export interface IdxTransaction {
Expand Down
1 change: 1 addition & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import * as crypto from './crypto';

export { default as OktaAuth } from './OktaAuth';
export * from './constants';
export * from './idx';
export * from './types';
export * from './tx';
export * from './errors';
Expand Down
20 changes: 6 additions & 14 deletions lib/tx/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import { STATE_TOKEN_KEY_NAME } from '../constants';
import { addStateToken } from './util';
import { AuthTransaction } from './AuthTransaction';

function transactionStatus(sdk, args) {
export function transactionStatus(sdk, args) {
args = addStateToken(sdk, args);
return post(sdk, sdk.getIssuerOrigin() + '/api/v1/authn', args, { withCredentials: true });
}

function resumeTransaction(sdk, args) {
export function resumeTransaction(sdk, args) {
if (!args || !args.stateToken) {
var stateToken = sdk.tx.exists._get(STATE_TOKEN_KEY_NAME);
if (stateToken) {
Expand All @@ -40,7 +40,7 @@ function resumeTransaction(sdk, args) {
});
}

function introspect (sdk, args) {
export function introspectAuthn (sdk, args) {
if (!args || !args.stateToken) {
var stateToken = sdk.tx.exists._get(STATE_TOKEN_KEY_NAME);
if (stateToken) {
Expand All @@ -57,29 +57,21 @@ function introspect (sdk, args) {
});
}

function transactionStep(sdk, args) {
export function transactionStep(sdk, args) {
args = addStateToken(sdk, args);
// v1 pipeline introspect API
return post(sdk, sdk.getIssuerOrigin() + '/api/v1/authn/introspect', args, { withCredentials: true });
}

function transactionExists(sdk) {
export function transactionExists(sdk) {
// We have a cookie state token
return !!sdk.tx.exists._get(STATE_TOKEN_KEY_NAME);
}

function postToTransaction(sdk, url, args, options?) {
export function postToTransaction(sdk, url, args, options?) {
options = Object.assign({ withCredentials: true }, options);
return post(sdk, url, args, options)
.then(function(res) {
return new AuthTransaction(sdk, res);
});
}

export {
transactionStatus,
resumeTransaction,
transactionExists,
postToTransaction,
introspect,
};
2 changes: 1 addition & 1 deletion samples/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const defaults = {

const spaDefaults = Object.assign({
redirectPath: '/login/callback',
flow: 'redirect',
authMethod: 'form',
scopes: ['openid', 'email'],
storage: 'sessionStorage',
requireUserSession: true,
Expand Down
16 changes: 8 additions & 8 deletions samples/generated/static-spa/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 390189f

Please sign in to comment.