-
-
Notifications
You must be signed in to change notification settings - Fork 466
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(experience): implement totp experience flow (#4589)
- Loading branch information
Showing
44 changed files
with
988 additions
and
78 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
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
11 changes: 11 additions & 0 deletions
11
packages/experience/src/Layout/SectionLayout/index.module.scss
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,11 @@ | ||
@use '@/scss/underscore' as _; | ||
|
||
.title { | ||
font: var(--font-title-3); | ||
} | ||
|
||
.description { | ||
font: var(--font-body-2); | ||
color: var(--color-type-secondary); | ||
margin-top: _.unit(1); | ||
} |
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,30 @@ | ||
import { type TFuncKey } from 'i18next'; | ||
import { type ReactNode } from 'react'; | ||
|
||
import DynamicT from '@/components/DynamicT'; | ||
|
||
import * as styles from './index.module.scss'; | ||
|
||
type Props = { | ||
title: TFuncKey; | ||
description: TFuncKey; | ||
titleProps?: Record<string, unknown>; | ||
descriptionProps?: Record<string, unknown>; | ||
children: ReactNode; | ||
}; | ||
|
||
const SectionLayout = ({ title, description, titleProps, descriptionProps, children }: Props) => { | ||
return ( | ||
<div> | ||
<div className={styles.title}> | ||
<DynamicT forKey={title} interpolation={titleProps} /> | ||
</div> | ||
<div className={styles.description}> | ||
<DynamicT forKey={description} interpolation={descriptionProps} /> | ||
</div> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
export default SectionLayout; |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions
29
packages/experience/src/components/Button/MfaFactorButton.module.scss
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,29 @@ | ||
@use '@/scss/underscore' as _; | ||
|
||
.mfaFactorButton { | ||
padding: _.unit(3) _.unit(4) _.unit(3) _.unit(3); | ||
height: unset; | ||
gap: _.unit(4); | ||
border-radius: 12px; | ||
} | ||
|
||
.icon { | ||
width: 20px; | ||
height: 20px; | ||
color: var(--color-type-secondary); | ||
} | ||
|
||
.title { | ||
flex: 1; | ||
@include _.flex-column; | ||
align-items: flex-start; | ||
|
||
.name { | ||
font: var(--font-body-1); | ||
} | ||
|
||
.description { | ||
font: var(--font-body-2); | ||
color: var(--color-type-secondary); | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
packages/experience/src/components/Button/MfaFactorButton.tsx
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,73 @@ | ||
import { MfaFactor } from '@logto/schemas'; | ||
import classNames from 'classnames'; | ||
import { type TFuncKey } from 'i18next'; | ||
|
||
import ArrowNext from '@/assets/icons/arrow-next.svg'; | ||
import FactorBackupCode from '@/assets/icons/factor-backup-code.svg'; | ||
import FactorTotp from '@/assets/icons/factor-totp.svg'; | ||
import FactorWebAuthn from '@/assets/icons/factor-webauthn.svg'; | ||
|
||
import DynamicT from '../DynamicT'; | ||
|
||
import * as mfaFactorButtonStyles from './MfaFactorButton.module.scss'; | ||
import * as styles from './index.module.scss'; | ||
|
||
export type Props = { | ||
factor: MfaFactor; | ||
isBinding: boolean; | ||
onClick?: () => void; | ||
}; | ||
|
||
const factorIcon: Record<MfaFactor, SvgComponent> = { | ||
[MfaFactor.TOTP]: FactorTotp, | ||
[MfaFactor.WebAuthn]: FactorWebAuthn, | ||
[MfaFactor.BackupCode]: FactorBackupCode, | ||
}; | ||
|
||
const factorName: Record<MfaFactor, TFuncKey> = { | ||
[MfaFactor.TOTP]: 'mfa.totp', | ||
[MfaFactor.WebAuthn]: 'mfa.webauthn', | ||
[MfaFactor.BackupCode]: 'mfa.backup_code', | ||
}; | ||
|
||
const factorDescription: Record<MfaFactor, TFuncKey> = { | ||
[MfaFactor.TOTP]: 'mfa.verify_totp_description', | ||
[MfaFactor.WebAuthn]: 'mfa.verify_webauthn_description', | ||
[MfaFactor.BackupCode]: 'mfa.verify_backup_code_description', | ||
}; | ||
|
||
const linkFactorDescription: Record<MfaFactor, TFuncKey> = { | ||
[MfaFactor.TOTP]: 'mfa.link_totp_description', | ||
[MfaFactor.WebAuthn]: 'mfa.link_webauthn_description', | ||
[MfaFactor.BackupCode]: 'mfa.link_backup_code_description', | ||
}; | ||
|
||
const MfaFactorButton = ({ factor, isBinding, onClick }: Props) => { | ||
const Icon = factorIcon[factor]; | ||
|
||
return ( | ||
<button | ||
className={classNames( | ||
styles.button, | ||
styles.secondary, | ||
styles.large, | ||
mfaFactorButtonStyles.mfaFactorButton | ||
)} | ||
type="button" | ||
onClick={onClick} | ||
> | ||
<Icon className={mfaFactorButtonStyles.icon} /> | ||
<div className={mfaFactorButtonStyles.title}> | ||
<div className={mfaFactorButtonStyles.name}> | ||
<DynamicT forKey={factorName[factor]} /> | ||
</div> | ||
<div className={mfaFactorButtonStyles.description}> | ||
<DynamicT forKey={(isBinding ? linkFactorDescription : factorDescription)[factor]} /> | ||
</div> | ||
</div> | ||
<ArrowNext className={mfaFactorButtonStyles.icon} /> | ||
</button> | ||
); | ||
}; | ||
|
||
export default MfaFactorButton; |
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,4 @@ | ||
import { yes } from '@silverhand/essentials'; | ||
|
||
export const isDevelopmentFeaturesEnabled = | ||
yes(process.env.DEV_FEATURES_ENABLED) || yes(process.env.INTEGRATION_TEST); |
6 changes: 6 additions & 0 deletions
6
packages/experience/src/containers/MfaFactorList/index.module.scss
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,6 @@ | ||
@use '@/scss/underscore' as _; | ||
|
||
.factorList { | ||
@include _.flex-column; | ||
gap: _.unit(3); | ||
} |
Oops, something went wrong.