u2fsign.tsx 931 B

1234567891011121314151617181920212223242526272829303132333435
  1. import {t} from 'sentry/locale';
  2. import U2fInterface from './u2finterface';
  3. const MESSAGES = {
  4. signin: t(
  5. 'Insert your U2F device or tap the button on it to confirm the sign-in request.'
  6. ),
  7. sudo: t('Alternatively you can use your U2F device to confirm the action.'),
  8. enroll: t(
  9. 'To enroll your U2F device insert it now or tap the button on it to activate it.'
  10. ),
  11. };
  12. type InterfaceProps = React.ComponentProps<typeof U2fInterface>;
  13. type Props = Omit<InterfaceProps, 'silentIfUnsupported' | 'flowMode'> & {
  14. displayMode?: 'signin' | 'enroll' | 'sudo';
  15. };
  16. function U2fSign({displayMode = 'signin', ...props}: Props) {
  17. const flowMode = displayMode === 'enroll' ? 'enroll' : 'sign';
  18. return (
  19. <U2fInterface
  20. {...props}
  21. silentIfUnsupported={displayMode === 'sudo'}
  22. flowMode={flowMode}
  23. >
  24. <p>{MESSAGES[displayMode] ?? null}</p>
  25. </U2fInterface>
  26. );
  27. }
  28. export default U2fSign;