Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add mfa types - OKTA-343852 #554

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 4.4.0

### Features

- [#554](https://github.com/okta/okta-auth-js/pull/554) Adds MFA types

## 4.3.0

### Features
Expand Down
33 changes: 30 additions & 3 deletions lib/tx/AuthTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,43 @@ interface PostToTransactionParams {
updatePhone?: boolean;
}

type AuthTransactionFunction = (obj?: any) => Promise<AuthTransaction>;

interface AuthTransactionFunctions {
poll?: Function;
// common
next?: AuthTransactionFunction;
cancel?: AuthTransactionFunction;
skip?: AuthTransactionFunction;
// locked_out
unlock?: AuthTransactionFunction;
// password
changePassword?: AuthTransactionFunction;
resetPassword?: AuthTransactionFunction;
// recovery
answer?: AuthTransactionFunction;
recovery?: AuthTransactionFunction;
// recovery_challenge
verify?: AuthTransactionFunction;
resend?: AuthTransactionFunction;
// mfa_enroll_activate
activate?: AuthTransactionFunction;
poll?: AuthTransactionFunction;
prev?: AuthTransactionFunction;
}

export class AuthTransaction implements TransactionState {
export class AuthTransaction implements TransactionState, AuthTransactionFunctions {
data: TransactionState;
cancel?: () => Promise<AuthTransaction>;
cancel?: AuthTransactionFunction;
stateToken?: string;
sessionToken?: string;
status: string;
user?: Record<string, any>;
factor?: Record<string, any>;
factors?: Array<Record<string, any> >;
policy?: Record<string, any>;
scopes?: Array<Record<string, any> >;
target?: Record<string, any>;
authentication?: Record<string, any>;
constructor(sdk, res = null) {
if (res) {
this.data = res;
Expand Down
7 changes: 7 additions & 0 deletions lib/tx/TransactionState.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
export class TransactionState {
stateToken?: string;
type?: string;
expiresAt?: string;
relayState?: string;
factorResult?: string;
factorType?: string;
recoveryToken?: string;
recoveryType?: string;
autoPush?: boolean | Function;
rememberDevice?: boolean | Function;
profile?: {
Expand Down
4 changes: 2 additions & 2 deletions samples/generated/static-spa/public/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<html>
<head>
<!-- In this sample, okta-auth-js assets are being served locally from node_modules. Assets are also available on CDN -->
<!-- https://global.oktacdn.com/okta-auth-js/4.1.2/okta-auth-js.polyfill.js -->
<!-- https://global.oktacdn.com/okta-auth-js/4.1.2/okta-auth-js.min.js -->
<!-- https://global.oktacdn.com/okta-auth-js/4.3.0/okta-auth-js.polyfill.js -->
<!-- https://global.oktacdn.com/okta-auth-js/4.3.0/okta-auth-js.min.js -->
<script src="/okta-auth-js.polyfill.js" type="text/javascript"></script>
<script src="/okta-auth-js.min.js" type="text/javascript"></script>

Expand Down