-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minimal idx factory for SIW gen3 (v2) (#1476)
OKTA-656620 Added factory `createMinimalOktaAuthIdx` to create minimal client for SIW Gen3
- Loading branch information
1 parent
89dcafd
commit 3710f59
Showing
34 changed files
with
550 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { OktaAuthOptionsConstructor } from '../../base/types'; | ||
import { StorageManagerConstructor } from '../../storage/types'; | ||
import { IdxTransactionManagerInterface, MinimalOktaAuthIdxInterface, OktaAuthIdxConstructor } from '../types/api'; | ||
import { IdxTransactionMeta } from '../types/meta'; | ||
import { IdxStorageManagerInterface } from '../types/storage'; | ||
import { OktaAuthIdxOptions } from '../types/options'; | ||
import { TransactionManagerConstructor, MinimalOktaOAuthInterface } from '../../oidc/types'; | ||
import { mixinMinimalIdx } from '../mixinMinimal'; | ||
import { createOktaAuthBase } from '../../base/factory'; | ||
import { mixinStorage } from '../../storage/mixin'; | ||
import { mixinHttp } from '../../http/mixin'; | ||
import { mixinSession } from '../../session/mixin'; | ||
import { mixinMinimalOAuth } from '../../oidc/mixin/minimal'; | ||
|
||
export function createMinimalOktaAuthIdx< | ||
M extends IdxTransactionMeta = IdxTransactionMeta, | ||
S extends IdxStorageManagerInterface<M> = IdxStorageManagerInterface<M>, | ||
O extends OktaAuthIdxOptions = OktaAuthIdxOptions, | ||
TM extends IdxTransactionManagerInterface = IdxTransactionManagerInterface | ||
>( | ||
StorageManagerConstructor: StorageManagerConstructor<S>, | ||
OptionsConstructor: OktaAuthOptionsConstructor<O>, | ||
TransactionManagerConstructor: TransactionManagerConstructor<TM> | ||
) | ||
: OktaAuthIdxConstructor< | ||
MinimalOktaAuthIdxInterface<M, S, O, TM> & MinimalOktaOAuthInterface<M, S, O, TM> | ||
> | ||
{ | ||
const Base = createOktaAuthBase(OptionsConstructor); | ||
const WithStorage = mixinStorage<S, O>(Base, StorageManagerConstructor); | ||
const WithHttp = mixinHttp<S, O>(WithStorage); | ||
const WithSession = mixinSession<S, O>(WithHttp); | ||
const WithOAuth = mixinMinimalOAuth<M, S, O, TM>(WithSession, TransactionManagerConstructor); | ||
// do not mixin core | ||
const WithIdx = mixinMinimalIdx(WithOAuth); | ||
return WithIdx; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './api'; | ||
export * from './OktaAuthIdx'; | ||
export * from './MinimalOktaAuthIdx'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/*! | ||
* Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved. | ||
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.") | ||
* | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and limitations under the License. | ||
* | ||
*/ | ||
|
||
import { makeIdxState } from '../idxState'; | ||
import { canProceed, proceed } from '../proceed'; | ||
import { startTransaction } from '../startTransaction'; | ||
import { | ||
clearTransactionMeta, | ||
createTransactionMeta, | ||
getSavedTransactionMeta, | ||
getTransactionMeta, | ||
isTransactionMetaValid, | ||
saveTransactionMeta | ||
} from '../transactionMeta'; | ||
import { MinimalIdxAPI, MinimalOktaAuthIdxInterface, OktaAuthIdxInterface } from '../types'; | ||
|
||
// Factory | ||
export function createMinimalIdxAPI(minimalSdk: MinimalOktaAuthIdxInterface): MinimalIdxAPI { | ||
const sdk = minimalSdk as OktaAuthIdxInterface; | ||
const boundStartTransaction = startTransaction.bind(null, sdk); | ||
const idx = { | ||
makeIdxResponse: makeIdxState.bind(null, sdk), | ||
|
||
start: boundStartTransaction, | ||
startTransaction: boundStartTransaction, // Use `start` instead. `startTransaction` will be removed in 7.0 | ||
proceed: proceed.bind(null, sdk), | ||
canProceed: canProceed.bind(null, sdk), | ||
|
||
getSavedTransactionMeta: getSavedTransactionMeta.bind(null, sdk), | ||
createTransactionMeta: createTransactionMeta.bind(null, sdk), | ||
getTransactionMeta: getTransactionMeta.bind(null, sdk), | ||
saveTransactionMeta: saveTransactionMeta.bind(null, sdk), | ||
clearTransactionMeta: clearTransactionMeta.bind(null, sdk), | ||
isTransactionMetaValid, | ||
}; | ||
return idx; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { OktaAuthConstructor } from '../base/types'; | ||
import { MinimalOktaOAuthInterface } from '../oidc/types'; | ||
import { | ||
IdxTransactionManagerInterface, | ||
OktaAuthIdxConstructor, | ||
OktaAuthIdxOptions, | ||
MinimalIdxAPI, | ||
WebauthnAPI, | ||
MinimalOktaAuthIdxInterface | ||
} from './types'; | ||
import { IdxTransactionMeta } from './types/meta'; | ||
import { IdxStorageManagerInterface } from './types/storage'; | ||
import { createMinimalIdxAPI } from '../idx/factory/minimalApi'; | ||
import * as webauthn from './webauthn'; | ||
|
||
export function mixinMinimalIdx | ||
< | ||
M extends IdxTransactionMeta = IdxTransactionMeta, | ||
S extends IdxStorageManagerInterface<M> = IdxStorageManagerInterface<M>, | ||
O extends OktaAuthIdxOptions = OktaAuthIdxOptions, | ||
TM extends IdxTransactionManagerInterface = IdxTransactionManagerInterface, | ||
TBase extends OktaAuthConstructor<MinimalOktaOAuthInterface<M, S, O, TM>> | ||
= OktaAuthConstructor<MinimalOktaOAuthInterface<M, S, O, TM>> | ||
> | ||
( | ||
Base: TBase | ||
): TBase & OktaAuthIdxConstructor<MinimalOktaAuthIdxInterface<M, S, O, TM>> | ||
{ | ||
return class OktaAuthIdx extends Base implements MinimalOktaAuthIdxInterface<M, S, O, TM> | ||
{ | ||
idx: MinimalIdxAPI; | ||
static webauthn: WebauthnAPI = webauthn; | ||
|
||
constructor(...args: any[]) { | ||
super(...args); | ||
this.idx = createMinimalIdxAPI(this); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { FlowIdentifier } from './FlowIdentifier'; | ||
import type { RemediationFlow } from '../flow/RemediationFlow'; | ||
|
||
export interface FlowSpecification { | ||
flow: FlowIdentifier; | ||
remediators: RemediationFlow; | ||
actions?: string[]; | ||
withCredentials?: boolean; | ||
} |
Oops, something went wrong.