@oneblink/apps-react 6.10.0-beta.5 → 6.10.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@ import useBooleanState from '../../hooks/useBooleanState';
6
6
  import { CopyToClipBoardIconButton } from '../CopyToClipboardIconButton';
7
7
  import SuccessSnackbar from '../SuccessSnackbar';
8
8
  import InputField from '../InputField';
9
- import LoadingButton from '../LoadingButton';
9
+ import { LoadingButton } from '@mui/lab';
10
10
  function MfaDialog({ onClose, onCompleted, mfaSetup, }) {
11
11
  const [code, setState] = React.useState('');
12
12
  const [hasSuccessfullySaved, showSuccessfullySaved, hideSuccessfullySaved] = useBooleanState(false);
@@ -1 +1 @@
1
- {"version":3,"file":"MfaDialog.js","sourceRoot":"","sources":["../../../src/components/mfa/MfaDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EACL,GAAG,EACH,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,aAAa,EACb,aAAa,EACb,MAAM,GACP,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,eAAe,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAA;AACxE,OAAO,eAAe,MAAM,oBAAoB,CAAA;AAChD,OAAO,UAAU,MAAM,eAAe,CAAA;AACtC,OAAO,aAAa,MAAM,kBAAkB,CAAA;AAE5C,SAAS,SAAS,CAAC,EACjB,OAAO,EACP,WAAW,EACX,QAAQ,GAKT;IACC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAC3C,MAAM,CAAC,oBAAoB,EAAE,qBA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nimport {\n Box,\n Collapse,\n Dialog,\n Grid,\n Link,\n Typography,\n DialogContent,\n DialogActions,\n Button,\n} from '@mui/material'\nimport { authService } from '@oneblink/apps'\nimport useBooleanState from '../../hooks/useBooleanState'\nimport { CopyToClipBoardIconButton } from '../CopyToClipboardIconButton'\nimport SuccessSnackbar from '../SuccessSnackbar'\nimport InputField from '../InputField'\nimport LoadingButton from '../LoadingButton'\n\nfunction MfaDialog({\n onClose,\n onCompleted,\n mfaSetup,\n}: {\n onClose: () => void\n onCompleted: () => void\n mfaSetup: Awaited<ReturnType<typeof authService.setupMfa>> | undefined\n}) {\n const [code, setState] = React.useState('')\n const [hasSuccessfullySaved, showSuccessfullySaved, hideSuccessfullySaved] =\n useBooleanState(false)\n const [isShowingSecretCode, showSecretCode, hideSecretCode] =\n useBooleanState(false)\n\n const qrcodeValue = React.useMemo(() => {\n if (mfaSetup) {\n return authService.generateMfaQrCodeUrl(mfaSetup)\n }\n }, [mfaSetup])\n\n const [isSaving, startSaving, stopSaving] = useBooleanState(false)\n const handleSave = React.useCallback(async () => {\n startSaving()\n if (!code || !mfaSetup) {\n return\n }\n\n await mfaSetup.mfaCodeCallback(code)\n onCompleted()\n stopSaving()\n showSuccessfullySaved()\n }, [\n code,\n mfaSetup,\n onCompleted,\n showSuccessfullySaved,\n startSaving,\n stopSaving,\n ])\n\n return (\n <React.Fragment>\n <Dialog open={!!mfaSetup} onClose={onClose} title=\"Complete MFA Setup\">\n <DialogContent dividers>\n <>\n <Typography variant=\"subtitle2\" gutterBottom>\n Authenticator App\n </Typography>\n <Typography variant=\"body2\" paragraph>\n Authenticator apps like{' '}\n <Link\n href=\"https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n Google Authenticator\n </Link>{' '}\n and{' '}\n <Link\n href=\"https://www.microsoft.com/en-us/security/mobile-authenticator-app\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n Microsoft Authenticator\n </Link>{' '}\n generate one-time passwords that are used as a second factor to\n verify your identity when prompted during sign-in.\n </Typography>\n <Typography variant=\"subtitle2\" gutterBottom>\n Scan the QR code\n </Typography>\n <Typography variant=\"body2\" paragraph>\n Use an authenticator app or browser extension to scan the QR code\n below.\n </Typography>\n\n <Box marginBottom={2}>\n <Grid container spacing={2} alignItems=\"center\">\n <Grid item xs={false}>\n <Box\n border={1}\n padding={2}\n borderRadius={1}\n borderColor=\"divider\"\n display=\"inline-block\"\n >\n <QRCodeSVG value={qrcodeValue || ''} />\n </Box>\n </Grid>\n <Grid item xs>\n <Typography variant=\"caption\" color=\"text.secondary\">\n Having trouble scanning the QR code?{' '}\n <Link onClick={showSecretCode} component=\"button\">\n Click here\n </Link>{' '}\n to display the setup key which can be manually entered in\n your authenticator app.\n </Typography>\n </Grid>\n </Grid>\n </Box>\n\n <Collapse in={isShowingSecretCode}>\n <Box marginBottom={2}>\n <InputField\n label=\"Setup Key\"\n value={mfaSetup?.secretCode || ''}\n fullWidth\n InputProps={{\n endAdornment: (\n <CopyToClipBoardIconButton\n text={mfaSetup?.secretCode || ''}\n />\n ),\n }}\n helperText={\n <>\n <Link onClick={hideSecretCode} component=\"button\">\n Click here\n </Link>{' '}\n to hide the setup key\n </>\n }\n />\n </Box>\n </Collapse>\n\n <Typography variant=\"subtitle2\" gutterBottom>\n Verify App\n </Typography>\n <Typography variant=\"body2\" paragraph>\n Enter the 6-digit code found in your authenticator app.\n </Typography>\n\n <InputField\n autoFocus\n margin=\"none\"\n name=\"code\"\n label=\"Code\"\n fullWidth\n placeholder=\"XXXXXX\"\n variant=\"outlined\"\n value={code}\n onChange={(event) => {\n const newValue = event.target.value\n setState(() => newValue)\n }}\n disabled={isSaving}\n data-cypress=\"mfa-dialog-code\"\n />\n </>\n </DialogContent>\n <DialogActions>\n <Button onClick={onClose} disabled={isSaving}>\n Cancel\n </Button>\n <LoadingButton\n variant=\"contained\"\n color=\"primary\"\n loading={isSaving}\n onClick={handleSave}\n >\n Save\n </LoadingButton>\n </DialogActions>\n </Dialog>\n\n <SuccessSnackbar\n open={hasSuccessfullySaved}\n onClose={hideSuccessfullySaved}\n >\n MFA has been successfully setup.\n </SuccessSnackbar>\n </React.Fragment>\n )\n}\n\nexport default React.memo(MfaDialog)\n"]}
1
+ {"version":3,"file":"MfaDialog.js","sourceRoot":"","sources":["../../../src/components/mfa/MfaDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EACL,GAAG,EACH,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,aAAa,EACb,aAAa,EACb,MAAM,GACP,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,eAAe,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAA;AACxE,OAAO,eAAe,MAAM,oBAAoB,CAAA;AAChD,OAAO,UAAU,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,SAAS,SAAS,CAAC,EACjB,OAAO,EACP,WAAW,EACX,QAAQ,GAKT;IACC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAC3C,MAAM,CAAC,oBAAoB,EAAE,qBAAqB,EAAE,qBAAqB,CAAC,GACxE,eAAe,CAAC,KAAK,CAAC,CAAA;IACxB,MAAM,CAAC,mBAAmB,EAAE,cAAc,EAAE,cAAc,CAAC,GACzD,eAAe,CAAC,KAAK,CAAC,CAAA;IAExB,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACrC,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,WAAW,CAAC,oBAAoB,CAAC,Q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AC,WAAW,EAAC,YAAY,uBAE/B;oBACb,oBAAC,UAAU,IAAC,OAAO,EAAC,OAAO,EAAC,SAAS,oEAExB;oBAEb,oBAAC,UAAU,IACT,SAAS,QACT,MAAM,EAAC,MAAM,EACb,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,MAAM,EACZ,SAAS,QACT,WAAW,EAAC,QAAQ,EACpB,OAAO,EAAC,UAAU,EAClB,KAAK,EAAE,IAAI,EACX,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;4BAClB,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAA;4BACnC,QAAQ,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAA;wBAC1B,CAAC,EACD,QAAQ,EAAE,QAAQ,kBACL,iBAAiB,GAC9B,CACD,CACW;YAChB,oBAAC,aAAa;gBACZ,oBAAC,MAAM,IAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,aAEnC;gBACT,oBAAC,aAAa,IACZ,OAAO,EAAC,WAAW,EACnB,KAAK,EAAC,SAAS,EACf,OAAO,EAAE,QAAQ,EACjB,OAAO,EAAE,UAAU,WAGL,CACF,CACT;QAET,oBAAC,eAAe,IACd,IAAI,EAAE,oBAAoB,EAC1B,OAAO,EAAE,qBAAqB,uCAGd,CACH,CAClB,CAAA;AACH,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport { QRCodeSVG } from 'qrcode.react'\nimport {\n Box,\n Collapse,\n Dialog,\n Grid,\n Link,\n Typography,\n DialogContent,\n DialogActions,\n Button,\n} from '@mui/material'\nimport { authService } from '@oneblink/apps'\nimport useBooleanState from '../../hooks/useBooleanState'\nimport { CopyToClipBoardIconButton } from '../CopyToClipboardIconButton'\nimport SuccessSnackbar from '../SuccessSnackbar'\nimport InputField from '../InputField'\nimport { LoadingButton } from '@mui/lab'\n\nfunction MfaDialog({\n onClose,\n onCompleted,\n mfaSetup,\n}: {\n onClose: () => void\n onCompleted: () => void\n mfaSetup: Awaited<ReturnType<typeof authService.setupMfa>> | undefined\n}) {\n const [code, setState] = React.useState('')\n const [hasSuccessfullySaved, showSuccessfullySaved, hideSuccessfullySaved] =\n useBooleanState(false)\n const [isShowingSecretCode, showSecretCode, hideSecretCode] =\n useBooleanState(false)\n\n const qrcodeValue = React.useMemo(() => {\n if (mfaSetup) {\n return authService.generateMfaQrCodeUrl(mfaSetup)\n }\n }, [mfaSetup])\n\n const [isSaving, startSaving, stopSaving] = useBooleanState(false)\n const handleSave = React.useCallback(async () => {\n startSaving()\n if (!code || !mfaSetup) {\n return\n }\n\n await mfaSetup.mfaCodeCallback(code)\n onCompleted()\n stopSaving()\n showSuccessfullySaved()\n }, [\n code,\n mfaSetup,\n onCompleted,\n showSuccessfullySaved,\n startSaving,\n stopSaving,\n ])\n\n return (\n <React.Fragment>\n <Dialog open={!!mfaSetup} onClose={onClose} title=\"Complete MFA Setup\">\n <DialogContent dividers>\n <>\n <Typography variant=\"subtitle2\" gutterBottom>\n Authenticator App\n </Typography>\n <Typography variant=\"body2\" paragraph>\n Authenticator apps like{' '}\n <Link\n href=\"https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n Google Authenticator\n </Link>{' '}\n and{' '}\n <Link\n href=\"https://www.microsoft.com/en-us/security/mobile-authenticator-app\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n Microsoft Authenticator\n </Link>{' '}\n generate one-time passwords that are used as a second factor to\n verify your identity when prompted during sign-in.\n </Typography>\n <Typography variant=\"subtitle2\" gutterBottom>\n Scan the QR code\n </Typography>\n <Typography variant=\"body2\" paragraph>\n Use an authenticator app or browser extension to scan the QR code\n below.\n </Typography>\n\n <Box marginBottom={2}>\n <Grid container spacing={2} alignItems=\"center\">\n <Grid item xs={false}>\n <Box\n border={1}\n padding={2}\n borderRadius={1}\n borderColor=\"divider\"\n display=\"inline-block\"\n >\n <QRCodeSVG value={qrcodeValue || ''} />\n </Box>\n </Grid>\n <Grid item xs>\n <Typography variant=\"caption\" color=\"text.secondary\">\n Having trouble scanning the QR code?{' '}\n <Link onClick={showSecretCode} component=\"button\">\n Click here\n </Link>{' '}\n to display the setup key which can be manually entered in\n your authenticator app.\n </Typography>\n </Grid>\n </Grid>\n </Box>\n\n <Collapse in={isShowingSecretCode}>\n <Box marginBottom={2}>\n <InputField\n label=\"Setup Key\"\n value={mfaSetup?.secretCode || ''}\n fullWidth\n InputProps={{\n endAdornment: (\n <CopyToClipBoardIconButton\n text={mfaSetup?.secretCode || ''}\n />\n ),\n }}\n helperText={\n <>\n <Link onClick={hideSecretCode} component=\"button\">\n Click here\n </Link>{' '}\n to hide the setup key\n </>\n }\n />\n </Box>\n </Collapse>\n\n <Typography variant=\"subtitle2\" gutterBottom>\n Verify App\n </Typography>\n <Typography variant=\"body2\" paragraph>\n Enter the 6-digit code found in your authenticator app.\n </Typography>\n\n <InputField\n autoFocus\n margin=\"none\"\n name=\"code\"\n label=\"Code\"\n fullWidth\n placeholder=\"XXXXXX\"\n variant=\"outlined\"\n value={code}\n onChange={(event) => {\n const newValue = event.target.value\n setState(() => newValue)\n }}\n disabled={isSaving}\n data-cypress=\"mfa-dialog-code\"\n />\n </>\n </DialogContent>\n <DialogActions>\n <Button onClick={onClose} disabled={isSaving}>\n Cancel\n </Button>\n <LoadingButton\n variant=\"contained\"\n color=\"primary\"\n loading={isSaving}\n onClick={handleSave}\n >\n Save\n </LoadingButton>\n </DialogActions>\n </Dialog>\n\n <SuccessSnackbar\n open={hasSuccessfullySaved}\n onClose={hideSuccessfullySaved}\n >\n MFA has been successfully setup.\n </SuccessSnackbar>\n </React.Fragment>\n )\n}\n\nexport default React.memo(MfaDialog)\n"]}
@@ -8,7 +8,7 @@ type Props = {
8
8
  };
9
9
  /**
10
10
  * React Component that provides a mechanism for app users to configure Multi
11
- * Factor Authentication. `<AppUserMfaProvider />` must be provided above this
11
+ * Factor Authentication. `<MfaProvider />` must be provided above this
12
12
  * component in the component tree.
13
13
  *
14
14
  * #### Example
@@ -16,7 +16,7 @@ type Props = {
16
16
  * ```js
17
17
  * import * as React from 'react'
18
18
  * import {
19
- * AppUserMfaProvider,
19
+ * MfaProvider,
20
20
  * MultiFactorAuthentication,
21
21
  * } from '@oneblink/apps-react'
22
22
  *
@@ -26,9 +26,9 @@ type Props = {
26
26
  *
27
27
  * function App() {
28
28
  * return (
29
- * <AppUserMfaProvider>
29
+ * <MfaProvider>
30
30
  * <Component />
31
- * </AppUserMfaProvider>
31
+ * </MfaProvider>
32
32
  * )
33
33
  * }
34
34
  *
@@ -5,12 +5,12 @@ import ConfirmDialog from '../ConfirmDialog';
5
5
  import MfaDialog from './MfaDialog';
6
6
  import ErrorSnackbar from '../ErrorSnackbar';
7
7
  import MaterialIcon from '../MaterialIcon';
8
- import useAppUserMfa from '../../hooks/useAppUserMfa';
8
+ import useMfa from '../../hooks/useMfa';
9
9
  import ErrorMessage from '../messages/ErrorMessage';
10
10
  export const LargeIcon = styled(Icon)(({ theme }) => ({
11
11
  fontSize: `${theme.typography.h4.fontSize} !important`,
12
12
  }));
13
- function MfaStatus({ isExternalIdentityProviderUser, isLoading, loadingError, loadAppUserMfa, isMfaEnabled, }) {
13
+ function MfaStatus({ isExternalIdentityProviderUser, isLoading, loadingError, loadMfa, isMfaEnabled, }) {
14
14
  if (isExternalIdentityProviderUser)
15
15
  return null;
16
16
  if (isLoading) {
@@ -20,7 +20,7 @@ function MfaStatus({ isExternalIdentityProviderUser, isLoading, loadingError, lo
20
20
  }
21
21
  if (loadingError) {
22
22
  return (React.createElement("div", null,
23
- React.createElement(ErrorMessage, { title: "Error Loading Multi Factor Authentication Configuration", onTryAgain: loadAppUserMfa }, loadingError.message)));
23
+ React.createElement(ErrorMessage, { title: "Error Loading Multi Factor Authentication Configuration", onTryAgain: loadMfa }, loadingError.message)));
24
24
  }
25
25
  if (isMfaEnabled) {
26
26
  return (React.createElement(Chip, { label: "Enabled", icon: React.createElement(MaterialIcon, { color: "success" }, "verified_user") }));
@@ -28,7 +28,7 @@ function MfaStatus({ isExternalIdentityProviderUser, isLoading, loadingError, lo
28
28
  return (React.createElement(Chip, { label: "Disabled", icon: React.createElement(MaterialIcon, { color: "warning" }, "remove_moderator") }));
29
29
  }
30
30
  function MfaSetup({ ssoSetupUrl, isExternalIdentityProviderUser, }) {
31
- const { setupError, isMfaEnabled, isDisablingMfa, isSettingUpMfa, mfaSetup, beginMfaSetup, cancelMfaSetup, completeMfaSetup, clearMfaSetupError, beginDisablingMfa, completeDisablingMfa, cancelDisablingMfa, } = useAppUserMfa();
31
+ const { setupError, isMfaEnabled, isDisablingMfa, isSettingUpMfa, mfaSetup, beginMfaSetup, cancelMfaSetup, completeMfaSetup, clearMfaSetupError, beginDisablingMfa, completeDisablingMfa, cancelDisablingMfa, } = useMfa();
32
32
  if (ssoSetupUrl) {
33
33
  return (React.createElement(Grid, { item: true },
34
34
  React.createElement(Button, { variant: "outlined", size: "small", component: "a", href: ssoSetupUrl, target: "_blank", rel: "noopener noreferrer", "data-cypress": "configure-mfa-button" }, "Configure MFA")));
@@ -57,7 +57,7 @@ function MfaSetup({ ssoSetupUrl, isExternalIdentityProviderUser, }) {
57
57
  }
58
58
  /**
59
59
  * React Component that provides a mechanism for app users to configure Multi
60
- * Factor Authentication. `<AppUserMfaProvider />` must be provided above this
60
+ * Factor Authentication. `<MfaProvider />` must be provided above this
61
61
  * component in the component tree.
62
62
  *
63
63
  * #### Example
@@ -65,7 +65,7 @@ function MfaSetup({ ssoSetupUrl, isExternalIdentityProviderUser, }) {
65
65
  * ```js
66
66
  * import * as React from 'react'
67
67
  * import {
68
- * AppUserMfaProvider,
68
+ * MfaProvider,
69
69
  * MultiFactorAuthentication,
70
70
  * } from '@oneblink/apps-react'
71
71
  *
@@ -75,9 +75,9 @@ function MfaSetup({ ssoSetupUrl, isExternalIdentityProviderUser, }) {
75
75
  *
76
76
  * function App() {
77
77
  * return (
78
- * <AppUserMfaProvider>
78
+ * <MfaProvider>
79
79
  * <Component />
80
- * </AppUserMfaProvider>
80
+ * </MfaProvider>
81
81
  * )
82
82
  * }
83
83
  *
@@ -92,7 +92,7 @@ function MfaSetup({ ssoSetupUrl, isExternalIdentityProviderUser, }) {
92
92
  * @group Components
93
93
  */
94
94
  export default function MultiFactorAuthentication({ ssoSetupUrl, isExternalIdentityProviderUser, }) {
95
- const { loadingError, isLoading, isMfaEnabled, loadAppUserMfa } = useAppUserMfa();
95
+ const { loadingError, isLoading, isMfaEnabled, loadMfa } = useMfa();
96
96
  return (React.createElement(Grid, { item: true, xs: true, lg: 8 },
97
97
  React.createElement(Box, { padding: 3 },
98
98
  React.createElement(Paper, null,
@@ -102,7 +102,7 @@ export default function MultiFactorAuthentication({ ssoSetupUrl, isExternalIdent
102
102
  React.createElement(Typography, { variant: "h4", fontWeight: "light" },
103
103
  "Multi Factor Authentication",
104
104
  ' ',
105
- React.createElement(MfaStatus, { loadAppUserMfa: loadAppUserMfa, isLoading: isLoading, loadingError: loadingError, isMfaEnabled: isMfaEnabled, isExternalIdentityProviderUser: !!isExternalIdentityProviderUser })),
105
+ React.createElement(MfaStatus, { loadMfa: loadMfa, isLoading: isLoading, loadingError: loadingError, isMfaEnabled: isMfaEnabled, isExternalIdentityProviderUser: !!isExternalIdentityProviderUser })),
106
106
  React.createElement(Box, { marginY: 1 },
107
107
  React.createElement(Divider, null)),
108
108
  React.createElement(Typography, { variant: "body2", paragraph: true }, "Multi factor authentication (MFA), also known as two factor authentication (2FA), is a best practice that requires a second authentication factor in addition to user name and password sign-in credentials. We strongly recommend enabling MFA to enhance your account security."),
@@ -1 +1 @@
1
- {"version":3,"file":"MultiFactorAuthentication.js","sourceRoot":"","sources":["../../../src/components/mfa/MultiFactorAuthentication.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EACL,GAAG,EACH,MAAM,EAC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KAAK;gBACJ,oBAAC,GAAG,IAAC,OAAO,EAAE,CAAC;oBACb,oBAAC,IAAI,IAAC,SAAS,QAAC,OAAO,EAAE,CAAC,EAAE,UAAU,EAAC,QAAQ;wBAC7C,oBAAC,IAAI,IAAC,IAAI,QAAC,EAAE;4BACX,oBAAC,UAAU,IAAC,OAAO,EAAC,IAAI,EAAC,UAAU,EAAC,OAAO;;gCACb,GAAG;gCAC/B,oBAAC,SAAS,IACR,cAAc,EAAE,cAAc,EAC9B,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAC1B,8BAA8B,EAC5B,CAAC,CAAC,8BAA8B,GAElC,CACS;4BACb,oBAAC,GAAG,IAAC,OAAO,EAAE,CAAC;gCACb,oBAAC,OAAO,OAAG,CACP;4BACN,oBAAC,UAAU,IAAC,OAAO,EAAC,OAAO,EAAC,SAAS,8RAMxB;4BACb,oBAAC,IAAI,IAAC,SAAS,QAAC,cAAc,EAAC,UAAU,EAAC,OAAO,EAAE,CAAC;gCAClD,oBAAC,QAAQ,IACP,8BAA8B,EAC5B,CAAC,CAAC,8BAA8B,EAElC,WAAW,EAAE,WAAW,IAAI,EAAE,GAC9B,CACG,CACF,CACF,CACH,CACA,CACJ,CACD,CACR,CAAA;AACH,CAAC","sourcesContent":["import * as React from 'react'\nimport {\n Box,\n Button,\n Chip,\n CircularProgress,\n Divider,\n Grid,\n Icon,\n Paper,\n Tooltip,\n Typography,\n styled,\n} from '@mui/material'\nimport { LoadingButton } from '@mui/lab'\nimport ConfirmDialog from '../ConfirmDialog'\nimport MfaDialog from './MfaDialog'\nimport ErrorSnackbar from '../ErrorSnackbar'\nimport MaterialIcon from '../MaterialIcon'\nimport useAppUserMfa from '../../hooks/useAppUserMfa'\nimport ErrorMessage from '../messages/ErrorMessage'\n\nexport const LargeIcon = styled(Icon)(({ theme }) => ({\n fontSize: `${theme.typography.h4.fontSize} !important`,\n}))\n\ntype Props = {\n ssoSetupUrl?: string\n isExternalIdentityProviderUser?: boolean\n}\n\ntype MfaStatusProps = {\n isExternalIdentityProviderUser: boolean\n isLoading: boolean\n isMfaEnabled: boolean\n loadAppUserMfa: () => void\n loadingError?: Error\n}\n\nfunction MfaStatus({\n isExternalIdentityProviderUser,\n isLoading,\n loadingError,\n loadAppUserMfa,\n isMfaEnabled,\n}: MfaStatusProps) {\n if (isExternalIdentityProviderUser) return null\n\n if (isLoading) {\n return (\n <Box padding={3}>\n <Grid container justifyContent=\"center\">\n <CircularProgress />\n </Grid>\n </Box>\n )\n }\n\n if (loadingError) {\n return (\n <div>\n <ErrorMessage\n title=\"Error Loading Multi Factor Authentication Configuration\"\n onTryAgain={loadAppUserMfa}\n >\n {loadingError.message}\n </ErrorMessage>\n </div>\n )\n }\n\n if (isMfaEnabled) {\n return (\n <Chip\n label=\"Enabled\"\n icon={<MaterialIcon color=\"success\">verified_user</MaterialIcon>}\n />\n )\n }\n\n return (\n <Chip\n label=\"Disabled\"\n icon={<MaterialIcon color=\"warning\">remove_moderator</MaterialIcon>}\n />\n )\n}\n\nfunction MfaSetup({\n ssoSetupUrl,\n isExternalIdentityProviderUser,\n}: {\n ssoSetupUrl: string\n isExternalIdentityProviderUser: boolean\n}) {\n const {\n setupError,\n isMfaEnabled,\n isDisablingMfa,\n isSettingUpMfa,\n mfaSetup,\n beginMfaSetup,\n cancelMfaSetup,\n completeMfaSetup,\n clearMfaSetupError,\n beginDisablingMfa,\n completeDisablingMfa,\n cancelDisablingMfa,\n } = useAppUserMfa()\n\n if (ssoSetupUrl) {\n return (\n <Grid item>\n <Button\n variant=\"outlined\"\n size=\"small\"\n component=\"a\"\n href={ssoSetupUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n data-cypress=\"configure-mfa-button\"\n >\n Configure MFA\n </Button>\n </Grid>\n )\n }\n\n if (isExternalIdentityProviderUser) {\n return (\n <Grid item>\n <Tooltip title=\"MFA must be configured in your login provider.\">\n <span>\n <Button\n variant=\"outlined\"\n size=\"small\"\n disabled={isExternalIdentityProviderUser}\n data-cypress=\"configure-mfa-button\"\n >\n Configure MFA\n </Button>\n </span>\n </Tooltip>\n </Grid>\n )\n }\n\n return (\n <>\n <Grid item>\n <Button\n variant=\"outlined\"\n size=\"small\"\n disabled={!isMfaEnabled}\n data-cypress=\"disable-mfa-button\"\n onClick={beginDisablingMfa}\n >\n Disable MFA\n </Button>\n <ConfirmDialog\n isOpen={isDisablingMfa}\n onClose={cancelDisablingMfa}\n onConfirm={completeDisablingMfa}\n title=\"Please Confirm\"\n confirmButtonText=\"Disable MFA\"\n confirmButtonIcon={<MaterialIcon>remove_moderator</MaterialIcon>}\n cypress={{\n dialog: 'disable-mfa-dialog',\n confirmButton: 'disable-mfa-dialog-confirm-button',\n cancelButton: 'disable-mfa-dialog-cancel-button',\n error: 'disable-mfa-dialog-error-message',\n }}\n >\n <Typography variant=\"body2\">\n Are you sure want to disable multi factor authentication (MFA)?\n </Typography>\n </ConfirmDialog>\n </Grid>\n\n <Grid item>\n <LoadingButton\n variant=\"contained\"\n size=\"small\"\n loading={isSettingUpMfa}\n disabled={isMfaEnabled}\n onClick={beginMfaSetup}\n data-cypress=\"setup-mfa-button\"\n >\n Setup MFA\n </LoadingButton>\n <MfaDialog\n mfaSetup={mfaSetup}\n onClose={cancelMfaSetup}\n onCompleted={completeMfaSetup}\n />\n </Grid>\n <ErrorSnackbar open={!!setupError} onClose={clearMfaSetupError}>\n <span data-cypress=\"mfa-setup-error-message\">\n {setupError?.message}\n </span>\n </ErrorSnackbar>\n </>\n )\n}\n/**\n * React Component that provides a mechanism for app users to configure Multi\n * Factor Authentication. `<AppUserMfaProvider />` must be provided above this\n * component in the component tree.\n *\n * #### Example\n *\n * ```js\n * import * as React from 'react'\n * import {\n * AppUserMfaProvider,\n * MultiFactorAuthentication,\n * } from '@oneblink/apps-react'\n *\n * function Component() {\n * return <MultiFactorAuthentication />\n * }\n *\n * function App() {\n * return (\n * <AppUserMfaProvider>\n * <Component />\n * </AppUserMfaProvider>\n * )\n * }\n *\n * const root = document.getElementById('root')\n * if (root) {\n * ReactDOM.render(<App />, root)\n * }\n * ```\n *\n * @param props\n * @returns\n * @group Components\n */\nexport default function MultiFactorAuthentication({\n ssoSetupUrl,\n isExternalIdentityProviderUser,\n}: Props) {\n const { loadingError, isLoading, isMfaEnabled, loadAppUserMfa } =\n useAppUserMfa()\n\n return (\n <Grid item xs={true} lg={8}>\n <Box padding={3}>\n <Paper>\n <Box padding={3}>\n <Grid container spacing={2} alignItems=\"center\">\n <Grid item xs>\n <Typography variant=\"h4\" fontWeight=\"light\">\n Multi Factor Authentication{' '}\n <MfaStatus\n loadAppUserMfa={loadAppUserMfa}\n isLoading={isLoading}\n loadingError={loadingError}\n isMfaEnabled={isMfaEnabled}\n isExternalIdentityProviderUser={\n !!isExternalIdentityProviderUser\n }\n />\n </Typography>\n <Box marginY={1}>\n <Divider />\n </Box>\n <Typography variant=\"body2\" paragraph>\n Multi factor authentication (MFA), also known as two factor\n authentication (2FA), is a best practice that requires a\n second authentication factor in addition to user name and\n password sign-in credentials. We strongly recommend enabling\n MFA to enhance your account security.\n </Typography>\n <Grid container justifyContent=\"flex-end\" spacing={1}>\n <MfaSetup\n isExternalIdentityProviderUser={\n !!isExternalIdentityProviderUser\n }\n ssoSetupUrl={ssoSetupUrl || ''}\n />\n </Grid>\n </Grid>\n </Grid>\n </Box>\n </Paper>\n </Box>\n </Grid>\n )\n}\n"]}
1
+ {"version":3,"file":"MultiFactorAuthentication.js","sourceRoot":"","sources":["../../../src/components/mfa/MultiFactorAuthentication.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EACL,GAAG,EACH,MAAM,EACN,IAAI,EACJ,gBAAgB,EAChB,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,OAAO,EACP,UAAU,EACV,MAAM,GACP,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,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QAAC,EAAE;4BACX,oBAAC,UAAU,IAAC,OAAO,EAAC,IAAI,EAAC,UAAU,EAAC,OAAO;;gCACb,GAAG;gCAC/B,oBAAC,SAAS,IACR,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAC1B,8BAA8B,EAC5B,CAAC,CAAC,8BAA8B,GAElC,CACS;4BACb,oBAAC,GAAG,IAAC,OAAO,EAAE,CAAC;gCACb,oBAAC,OAAO,OAAG,CACP;4BACN,oBAAC,UAAU,IAAC,OAAO,EAAC,OAAO,EAAC,SAAS,8RAMxB;4BACb,oBAAC,IAAI,IAAC,SAAS,QAAC,cAAc,EAAC,UAAU,EAAC,OAAO,EAAE,CAAC;gCAClD,oBAAC,QAAQ,IACP,8BAA8B,EAC5B,CAAC,CAAC,8BAA8B,EAElC,WAAW,EAAE,WAAW,IAAI,EAAE,GAC9B,CACG,CACF,CACF,CACH,CACA,CACJ,CACD,CACR,CAAA;AACH,CAAC","sourcesContent":["import * as React from 'react'\nimport {\n Box,\n Button,\n Chip,\n CircularProgress,\n Divider,\n Grid,\n Icon,\n Paper,\n Tooltip,\n Typography,\n styled,\n} from '@mui/material'\nimport { LoadingButton } from '@mui/lab'\nimport ConfirmDialog from '../ConfirmDialog'\nimport MfaDialog from './MfaDialog'\nimport ErrorSnackbar from '../ErrorSnackbar'\nimport MaterialIcon from '../MaterialIcon'\nimport useMfa from '../../hooks/useMfa'\nimport ErrorMessage from '../messages/ErrorMessage'\n\nexport const LargeIcon = styled(Icon)(({ theme }) => ({\n fontSize: `${theme.typography.h4.fontSize} !important`,\n}))\n\ntype Props = {\n ssoSetupUrl?: string\n isExternalIdentityProviderUser?: boolean\n}\n\ntype MfaStatusProps = {\n isExternalIdentityProviderUser: boolean\n isLoading: boolean\n isMfaEnabled: boolean\n loadMfa: () => void\n loadingError?: Error\n}\n\nfunction MfaStatus({\n isExternalIdentityProviderUser,\n isLoading,\n loadingError,\n loadMfa,\n isMfaEnabled,\n}: MfaStatusProps) {\n if (isExternalIdentityProviderUser) return null\n\n if (isLoading) {\n return (\n <Box padding={3}>\n <Grid container justifyContent=\"center\">\n <CircularProgress />\n </Grid>\n </Box>\n )\n }\n\n if (loadingError) {\n return (\n <div>\n <ErrorMessage\n title=\"Error Loading Multi Factor Authentication Configuration\"\n onTryAgain={loadMfa}\n >\n {loadingError.message}\n </ErrorMessage>\n </div>\n )\n }\n\n if (isMfaEnabled) {\n return (\n <Chip\n label=\"Enabled\"\n icon={<MaterialIcon color=\"success\">verified_user</MaterialIcon>}\n />\n )\n }\n\n return (\n <Chip\n label=\"Disabled\"\n icon={<MaterialIcon color=\"warning\">remove_moderator</MaterialIcon>}\n />\n )\n}\n\nfunction MfaSetup({\n ssoSetupUrl,\n isExternalIdentityProviderUser,\n}: {\n ssoSetupUrl: string\n isExternalIdentityProviderUser: boolean\n}) {\n const {\n setupError,\n isMfaEnabled,\n isDisablingMfa,\n isSettingUpMfa,\n mfaSetup,\n beginMfaSetup,\n cancelMfaSetup,\n completeMfaSetup,\n clearMfaSetupError,\n beginDisablingMfa,\n completeDisablingMfa,\n cancelDisablingMfa,\n } = useMfa()\n\n if (ssoSetupUrl) {\n return (\n <Grid item>\n <Button\n variant=\"outlined\"\n size=\"small\"\n component=\"a\"\n href={ssoSetupUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n data-cypress=\"configure-mfa-button\"\n >\n Configure MFA\n </Button>\n </Grid>\n )\n }\n\n if (isExternalIdentityProviderUser) {\n return (\n <Grid item>\n <Tooltip title=\"MFA must be configured in your login provider.\">\n <span>\n <Button\n variant=\"outlined\"\n size=\"small\"\n disabled={isExternalIdentityProviderUser}\n data-cypress=\"configure-mfa-button\"\n >\n Configure MFA\n </Button>\n </span>\n </Tooltip>\n </Grid>\n )\n }\n\n return (\n <>\n <Grid item>\n <Button\n variant=\"outlined\"\n size=\"small\"\n disabled={!isMfaEnabled}\n data-cypress=\"disable-mfa-button\"\n onClick={beginDisablingMfa}\n >\n Disable MFA\n </Button>\n <ConfirmDialog\n isOpen={isDisablingMfa}\n onClose={cancelDisablingMfa}\n onConfirm={completeDisablingMfa}\n title=\"Please Confirm\"\n confirmButtonText=\"Disable MFA\"\n confirmButtonIcon={<MaterialIcon>remove_moderator</MaterialIcon>}\n cypress={{\n dialog: 'disable-mfa-dialog',\n confirmButton: 'disable-mfa-dialog-confirm-button',\n cancelButton: 'disable-mfa-dialog-cancel-button',\n error: 'disable-mfa-dialog-error-message',\n }}\n >\n <Typography variant=\"body2\">\n Are you sure want to disable multi factor authentication (MFA)?\n </Typography>\n </ConfirmDialog>\n </Grid>\n\n <Grid item>\n <LoadingButton\n variant=\"contained\"\n size=\"small\"\n loading={isSettingUpMfa}\n disabled={isMfaEnabled}\n onClick={beginMfaSetup}\n data-cypress=\"setup-mfa-button\"\n >\n Setup MFA\n </LoadingButton>\n <MfaDialog\n mfaSetup={mfaSetup}\n onClose={cancelMfaSetup}\n onCompleted={completeMfaSetup}\n />\n </Grid>\n <ErrorSnackbar open={!!setupError} onClose={clearMfaSetupError}>\n <span data-cypress=\"mfa-setup-error-message\">\n {setupError?.message}\n </span>\n </ErrorSnackbar>\n </>\n )\n}\n/**\n * React Component that provides a mechanism for app users to configure Multi\n * Factor Authentication. `<MfaProvider />` must be provided above this\n * component in the component tree.\n *\n * #### Example\n *\n * ```js\n * import * as React from 'react'\n * import {\n * MfaProvider,\n * MultiFactorAuthentication,\n * } from '@oneblink/apps-react'\n *\n * function Component() {\n * return <MultiFactorAuthentication />\n * }\n *\n * function App() {\n * return (\n * <MfaProvider>\n * <Component />\n * </MfaProvider>\n * )\n * }\n *\n * const root = document.getElementById('root')\n * if (root) {\n * ReactDOM.render(<App />, root)\n * }\n * ```\n *\n * @param props\n * @returns\n * @group Components\n */\nexport default function MultiFactorAuthentication({\n ssoSetupUrl,\n isExternalIdentityProviderUser,\n}: Props) {\n const { loadingError, isLoading, isMfaEnabled, loadMfa } =\n useMfa()\n\n return (\n <Grid item xs={true} lg={8}>\n <Box padding={3}>\n <Paper>\n <Box padding={3}>\n <Grid container spacing={2} alignItems=\"center\">\n <Grid item xs>\n <Typography variant=\"h4\" fontWeight=\"light\">\n Multi Factor Authentication{' '}\n <MfaStatus\n loadMfa={loadMfa}\n isLoading={isLoading}\n loadingError={loadingError}\n isMfaEnabled={isMfaEnabled}\n isExternalIdentityProviderUser={\n !!isExternalIdentityProviderUser\n }\n />\n </Typography>\n <Box marginY={1}>\n <Divider />\n </Box>\n <Typography variant=\"body2\" paragraph>\n Multi factor authentication (MFA), also known as two factor\n authentication (2FA), is a best practice that requires a\n second authentication factor in addition to user name and\n password sign-in credentials. We strongly recommend enabling\n MFA to enhance your account security.\n </Typography>\n <Grid container justifyContent=\"flex-end\" spacing={1}>\n <MfaSetup\n isExternalIdentityProviderUser={\n !!isExternalIdentityProviderUser\n }\n ssoSetupUrl={ssoSetupUrl || ''}\n />\n </Grid>\n </Grid>\n </Grid>\n </Box>\n </Paper>\n </Box>\n </Grid>\n )\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { authService } from '@oneblink/apps';
3
- type AppUserMfaState = {
3
+ type MfaState = {
4
4
  isLoading: boolean;
5
5
  isMfaEnabled: boolean;
6
6
  loadingError?: Error;
@@ -9,7 +9,7 @@ type AppUserMfaState = {
9
9
  setupError?: Error;
10
10
  mfaSetup?: Awaited<ReturnType<typeof authService.setupMfa>>;
11
11
  };
12
- export declare const AppUserMfaContext: React.Context<AppUserMfaState & {
12
+ export declare const MfaContext: React.Context<MfaState & {
13
13
  beginMfaSetup: () => void;
14
14
  cancelMfaSetup: () => void;
15
15
  completeMfaSetup: () => void;
@@ -17,7 +17,7 @@ export declare const AppUserMfaContext: React.Context<AppUserMfaState & {
17
17
  cancelDisablingMfa: () => void;
18
18
  completeDisablingMfa: () => void;
19
19
  clearMfaSetupError: () => void;
20
- loadAppUserMfa: () => void;
20
+ loadMfa: () => void;
21
21
  }>;
22
22
  /**
23
23
  * React Component that provides the context for the
@@ -31,21 +31,21 @@ export declare const AppUserMfaContext: React.Context<AppUserMfaState & {
31
31
  * ```js
32
32
  * import * as React from 'react'
33
33
  * import {
34
- * AppUserMfaProvider,
34
+ * MfaProvider,
35
35
  * useUserMeetsMfaRequirement,
36
36
  * } from '@oneblink/apps-react'
37
37
  *
38
38
  * function Component() {
39
39
  * const { isLoading, userMeetsMfaRequirement } =
40
40
  * useUserMeetsMfaRequirement(true)
41
- * // use App User MFA Requirement details here
41
+ * // use MFA Requirement details here
42
42
  * }
43
43
  *
44
44
  * function App() {
45
45
  * return (
46
- * <AppUserMfaProvider isExternalIdentityProviderUser={false}>
46
+ * <MfaProvider isExternalIdentityProviderUser={false}>
47
47
  * <Component />
48
- * </AppUserMfaProvider>
48
+ * </MfaProvider>
49
49
  * )
50
50
  * }
51
51
  *
@@ -59,11 +59,11 @@ export declare const AppUserMfaContext: React.Context<AppUserMfaState & {
59
59
  * @returns
60
60
  * @group Components
61
61
  */
62
- export declare function AppUserMfaProvider({ children, isExternalIdentityProviderUser, }: {
62
+ export declare function MfaProvider({ children, isExternalIdentityProviderUser, }: {
63
63
  children: React.ReactNode;
64
64
  isExternalIdentityProviderUser: boolean;
65
65
  }): React.JSX.Element;
66
- export default function useAppUserMfa(): AppUserMfaState & {
66
+ export default function useMfa(): MfaState & {
67
67
  beginMfaSetup: () => void;
68
68
  cancelMfaSetup: () => void;
69
69
  completeMfaSetup: () => void;
@@ -71,11 +71,11 @@ export default function useAppUserMfa(): AppUserMfaState & {
71
71
  cancelDisablingMfa: () => void;
72
72
  completeDisablingMfa: () => void;
73
73
  clearMfaSetupError: () => void;
74
- loadAppUserMfa: () => void;
74
+ loadMfa: () => void;
75
75
  };
76
76
  /**
77
77
  * React hook to get the state associated to the logged in user's MFA status.
78
- * Will throw an Error if used outside of the `<AppUserMfaProvider />`
78
+ * Will throw an Error if used outside of the `<MfaProvider />`
79
79
  * component.
80
80
  *
81
81
  * Example
@@ -83,21 +83,21 @@ export default function useAppUserMfa(): AppUserMfaState & {
83
83
  * ```js
84
84
  * import { useUserMeetsMfaRequirement } from '@oneblink/apps-react'
85
85
  *
86
- * const isAppUserMfaRequired = true
86
+ * const isMfaRequired = true
87
87
  *
88
88
  * function Component() {
89
89
  * const { isLoading, userMeetsMfaRequirement } =
90
- * useUserMeetsMfaRequirement(isAppUserMfaRequired)
90
+ * useUserMeetsMfaRequirement(isMfaRequired)
91
91
  * }
92
92
  * ```
93
93
  *
94
94
  * @returns
95
95
  * @group Hooks
96
96
  */
97
- export declare function useUserMeetsMfaRequirement(isAppUserMfaRequired: boolean): {
97
+ export declare function useUserMeetsMfaRequirement(isMfaRequired: boolean): {
98
98
  isLoading: boolean;
99
99
  loadingError: Error | undefined;
100
- loadAppUserMfa: () => void;
100
+ loadMfa: () => void;
101
101
  userMeetsMfaRequirement: boolean;
102
102
  };
103
103
  export {};
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { authService } from '@oneblink/apps';
3
- export const AppUserMfaContext = React.createContext({
3
+ export const MfaContext = React.createContext({
4
4
  isLoading: true,
5
5
  isMfaEnabled: false,
6
6
  isSettingUpMfa: false,
@@ -12,7 +12,7 @@ export const AppUserMfaContext = React.createContext({
12
12
  cancelDisablingMfa: () => { },
13
13
  completeDisablingMfa: () => { },
14
14
  clearMfaSetupError: () => { },
15
- loadAppUserMfa: () => { },
15
+ loadMfa: () => { },
16
16
  });
17
17
  /**
18
18
  * React Component that provides the context for the
@@ -26,21 +26,21 @@ export const AppUserMfaContext = React.createContext({
26
26
  * ```js
27
27
  * import * as React from 'react'
28
28
  * import {
29
- * AppUserMfaProvider,
29
+ * MfaProvider,
30
30
  * useUserMeetsMfaRequirement,
31
31
  * } from '@oneblink/apps-react'
32
32
  *
33
33
  * function Component() {
34
34
  * const { isLoading, userMeetsMfaRequirement } =
35
35
  * useUserMeetsMfaRequirement(true)
36
- * // use App User MFA Requirement details here
36
+ * // use MFA Requirement details here
37
37
  * }
38
38
  *
39
39
  * function App() {
40
40
  * return (
41
- * <AppUserMfaProvider isExternalIdentityProviderUser={false}>
41
+ * <MfaProvider isExternalIdentityProviderUser={false}>
42
42
  * <Component />
43
- * </AppUserMfaProvider>
43
+ * </MfaProvider>
44
44
  * )
45
45
  * }
46
46
  *
@@ -54,14 +54,14 @@ export const AppUserMfaContext = React.createContext({
54
54
  * @returns
55
55
  * @group Components
56
56
  */
57
- export function AppUserMfaProvider({ children, isExternalIdentityProviderUser, }) {
57
+ export function MfaProvider({ children, isExternalIdentityProviderUser, }) {
58
58
  const [state, setState] = React.useState({
59
59
  isLoading: !isExternalIdentityProviderUser,
60
60
  isMfaEnabled: false,
61
61
  isSettingUpMfa: false,
62
62
  isDisablingMfa: false,
63
63
  });
64
- const loadAppUserMfa = React.useCallback(async (abortSignal) => {
64
+ const loadMfa = React.useCallback(async (abortSignal) => {
65
65
  setState((currentState) => ({
66
66
  ...currentState,
67
67
  isLoading: true,
@@ -152,14 +152,14 @@ export function AppUserMfaProvider({ children, isExternalIdentityProviderUser, }
152
152
  if (isExternalIdentityProviderUser) {
153
153
  return;
154
154
  }
155
- loadAppUserMfa();
155
+ loadMfa();
156
156
  return () => { };
157
- }, [isExternalIdentityProviderUser, loadAppUserMfa]);
157
+ }, [isExternalIdentityProviderUser, loadMfa]);
158
158
  const value = React.useMemo(() => {
159
159
  return {
160
160
  ...state,
161
161
  clearMfaSetupError,
162
- loadAppUserMfa,
162
+ loadMfa,
163
163
  beginMfaSetup,
164
164
  cancelMfaSetup,
165
165
  completeMfaSetup,
@@ -170,7 +170,7 @@ export function AppUserMfaProvider({ children, isExternalIdentityProviderUser, }
170
170
  }, [
171
171
  state,
172
172
  clearMfaSetupError,
173
- loadAppUserMfa,
173
+ loadMfa,
174
174
  beginMfaSetup,
175
175
  cancelMfaSetup,
176
176
  completeMfaSetup,
@@ -178,14 +178,14 @@ export function AppUserMfaProvider({ children, isExternalIdentityProviderUser, }
178
178
  cancelDisablingMfa,
179
179
  completeDisablingMfa,
180
180
  ]);
181
- return (React.createElement(AppUserMfaContext.Provider, { value: value }, children));
181
+ return (React.createElement(MfaContext.Provider, { value: value }, children));
182
182
  }
183
- export default function useAppUserMfa() {
184
- return React.useContext(AppUserMfaContext);
183
+ export default function useMfa() {
184
+ return React.useContext(MfaContext);
185
185
  }
186
186
  /**
187
187
  * React hook to get the state associated to the logged in user's MFA status.
188
- * Will throw an Error if used outside of the `<AppUserMfaProvider />`
188
+ * Will throw an Error if used outside of the `<MfaProvider />`
189
189
  * component.
190
190
  *
191
191
  * Example
@@ -193,36 +193,36 @@ export default function useAppUserMfa() {
193
193
  * ```js
194
194
  * import { useUserMeetsMfaRequirement } from '@oneblink/apps-react'
195
195
  *
196
- * const isAppUserMfaRequired = true
196
+ * const isMfaRequired = true
197
197
  *
198
198
  * function Component() {
199
199
  * const { isLoading, userMeetsMfaRequirement } =
200
- * useUserMeetsMfaRequirement(isAppUserMfaRequired)
200
+ * useUserMeetsMfaRequirement(isMfaRequired)
201
201
  * }
202
202
  * ```
203
203
  *
204
204
  * @returns
205
205
  * @group Hooks
206
206
  */
207
- export function useUserMeetsMfaRequirement(isAppUserMfaRequired) {
208
- const context = React.useContext(AppUserMfaContext);
207
+ export function useUserMeetsMfaRequirement(isMfaRequired) {
208
+ const context = React.useContext(MfaContext);
209
209
  if (!context) {
210
- throw new Error(`"useUserMeetsMfaRequirement" hook was used outside of the "<AppUserMfaProvider />" component's children.`);
210
+ throw new Error(`"useUserMeetsMfaRequirement" hook was used outside of the "<MfaProvider />" component's children.`);
211
211
  }
212
- const { isLoading, loadingError, loadAppUserMfa, isMfaEnabled } = context;
213
- if (!isAppUserMfaRequired) {
212
+ const { isLoading, loadingError, loadMfa, isMfaEnabled } = context;
213
+ if (!isMfaRequired) {
214
214
  return {
215
215
  isLoading: false,
216
216
  loadingError: undefined,
217
217
  userMeetsMfaRequirement: true,
218
- loadAppUserMfa,
218
+ loadMfa,
219
219
  };
220
220
  }
221
221
  return {
222
222
  isLoading,
223
223
  loadingError,
224
- loadAppUserMfa,
224
+ loadMfa,
225
225
  userMeetsMfaRequirement: isMfaEnabled,
226
226
  };
227
227
  }
228
- //# sourceMappingURL=useAppUserMfa.js.map
228
+ //# sourceMappingURL=useMfa.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMfa.js","sourceRoot":"","sources":["../../src/hooks/useMfa.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAY5C,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC,aAAa,CAW3C;IACA,SAAS,EAAE,IAAI;IACf,YAAY,EAAE,KAAK;IACnB,cAAc,EAAE,KAAK;IACrB,cAAc,EAAE,KAAK;IACrB,aAAa,EAAE,GAAG,EAAE,GAAE,CAAC;IACvB,cAAc,EAAE,GAAG,EAAE,GAAE,CAAC;IACxB,gBAAgB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC1B,iBAAiB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC3B,kBAAkB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC5B,oBAAoB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC9B,kBAAkB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC5B,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;CAClB,CAAC,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,UAAU,WAAW,CAAC,EAC1B,QAAQ,EACR,8BAA8B,GAI/B;IACC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAW;QACjD,SAAS,EAAE,CAAC,8BAA8B;QAC1C,YAAY,EAAE,KAAK;QACnB,cAAc,EAAE,KAAK;QACrB,cAAc,EAAE,KAAK;KACtB,CAAC,CAAA;IAEF,MAAM,OAA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CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,0BAA0B,CAAC,aAAsB;IAC/D,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA;IAE5C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,mGAAmG,CACpG,CAAA;IACH,CAAC;IAED,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,OAAO,CAAA;IAElE,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO;YACL,SAAS,EAAE,KAAK;YAChB,YAAY,EAAE,SAAS;YACvB,uBAAuB,EAAE,IAAI;YAC7B,OAAO;SACR,CAAA;IACH,CAAC;IAED,OAAO;QACL,SAAS;QACT,YAAY;QACZ,OAAO;QACP,uBAAuB,EAAE,YAAY;KACtC,CAAA;AACH,CAAC","sourcesContent":["import * as React from 'react'\nimport { authService } from '@oneblink/apps'\n\ntype MfaState = {\n isLoading: boolean\n isMfaEnabled: boolean\n loadingError?: Error\n isSettingUpMfa: boolean\n isDisablingMfa: boolean\n setupError?: Error\n mfaSetup?: Awaited<ReturnType<typeof authService.setupMfa>>\n}\n\nexport const MfaContext = React.createContext<\n MfaState & {\n beginMfaSetup: () => void\n cancelMfaSetup: () => void\n completeMfaSetup: () => void\n beginDisablingMfa: () => void\n cancelDisablingMfa: () => void\n completeDisablingMfa: () => void\n clearMfaSetupError: () => void\n loadMfa: () => void\n }\n>({\n isLoading: true,\n isMfaEnabled: false,\n isSettingUpMfa: false,\n isDisablingMfa: false,\n beginMfaSetup: () => {},\n cancelMfaSetup: () => {},\n completeMfaSetup: () => {},\n beginDisablingMfa: () => {},\n cancelDisablingMfa: () => {},\n completeDisablingMfa: () => {},\n clearMfaSetupError: () => {},\n loadMfa: () => {},\n})\n\n/**\n * React Component that provides the context for the\n * `useUserMeetsMfaRequirement()` hook and `<MultiFactorAuthentication />`\n * component, to be used by components further down your component tree. **It\n * should only be included in your component tree once and ideally at the root\n * of the application.**\n *\n * #### Example\n *\n * ```js\n * import * as React from 'react'\n * import {\n * MfaProvider,\n * useUserMeetsMfaRequirement,\n * } from '@oneblink/apps-react'\n *\n * function Component() {\n * const { isLoading, userMeetsMfaRequirement } =\n * useUserMeetsMfaRequirement(true)\n * // use MFA Requirement details here\n * }\n *\n * function App() {\n * return (\n * <MfaProvider isExternalIdentityProviderUser={false}>\n * <Component />\n * </MfaProvider>\n * )\n * }\n *\n * const root = document.getElementById('root')\n * if (root) {\n * ReactDOM.render(<App />, root)\n * }\n * ```\n *\n * @param props\n * @returns\n * @group Components\n */\nexport function MfaProvider({\n children,\n isExternalIdentityProviderUser,\n}: {\n children: React.ReactNode\n isExternalIdentityProviderUser: boolean\n}) {\n const [state, setState] = React.useState<MfaState>({\n isLoading: !isExternalIdentityProviderUser,\n isMfaEnabled: false,\n isSettingUpMfa: false,\n isDisablingMfa: false,\n })\n\n const loadMfa = React.useCallback(\n async (abortSignal?: AbortSignal) => {\n setState((currentState) => ({\n ...currentState,\n isLoading: true,\n isMfaEnabled: false,\n loadingError: undefined,\n }))\n try {\n const newIsMfaEnabled = await authService.checkIsMfaEnabled()\n if (!abortSignal?.aborted) {\n setState((currentState) => ({\n ...currentState,\n isLoading: false,\n isMfaEnabled: newIsMfaEnabled,\n }))\n }\n } catch (error) {\n setState((currentState) => ({\n ...currentState,\n isLoading: false,\n loadingError: error as Error,\n }))\n }\n },\n [],\n )\n\n const clearMfaSetupError = React.useCallback(() => {\n setState((currentState) => ({\n ...currentState,\n setupError: undefined,\n }))\n }, [])\n\n const cancelMfaSetup = React.useCallback(() => {\n setState((currentState) => ({\n ...currentState,\n mfaSetup: undefined,\n }))\n }, [])\n\n const completeMfaSetup = React.useCallback(() => {\n setState((currentState) => ({\n ...currentState,\n isMfaEnabled: true,\n mfaSetup: undefined,\n }))\n }, [])\n\n const beginMfaSetup = React.useCallback(async () => {\n setState((currentState) => ({\n ...currentState,\n isSettingUpMfa: true,\n mfaSetup: undefined,\n setupError: undefined,\n }))\n try {\n const newMfaSetup = await authService.setupMfa()\n setState((currentState) => ({\n ...currentState,\n isSettingUpMfa: false,\n mfaSetup: newMfaSetup,\n }))\n } catch (error) {\n setState((currentState) => ({\n ...currentState,\n isSettingUpMfa: false,\n setupError: error as Error,\n }))\n }\n }, [])\n\n const beginDisablingMfa = React.useCallback(() => {\n setState((currentState) => ({\n ...currentState,\n isDisablingMfa: true,\n }))\n }, [])\n\n const cancelDisablingMfa = React.useCallback(() => {\n setState((currentState) => ({\n ...currentState,\n isDisablingMfa: false,\n }))\n }, [])\n\n const completeDisablingMfa = React.useCallback(async () => {\n await authService.disableMfa()\n setState((currentState) => ({\n ...currentState,\n isDisablingMfa: false,\n isMfaEnabled: false,\n }))\n }, [])\n\n React.useEffect(() => {\n if (isExternalIdentityProviderUser) {\n return\n }\n\n loadMfa()\n\n return () => {}\n }, [isExternalIdentityProviderUser, loadMfa])\n\n const value = React.useMemo(() => {\n return {\n ...state,\n clearMfaSetupError,\n loadMfa,\n beginMfaSetup,\n cancelMfaSetup,\n completeMfaSetup,\n beginDisablingMfa,\n cancelDisablingMfa,\n completeDisablingMfa,\n }\n }, [\n state,\n clearMfaSetupError,\n loadMfa,\n beginMfaSetup,\n cancelMfaSetup,\n completeMfaSetup,\n beginDisablingMfa,\n cancelDisablingMfa,\n completeDisablingMfa,\n ])\n\n return (\n <MfaContext.Provider value={value}>\n {children}\n </MfaContext.Provider>\n )\n}\n\nexport default function useMfa() {\n return React.useContext(MfaContext)\n}\n\n/**\n * React hook to get the state associated to the logged in user's MFA status.\n * Will throw an Error if used outside of the `<MfaProvider />`\n * component.\n *\n * Example\n *\n * ```js\n * import { useUserMeetsMfaRequirement } from '@oneblink/apps-react'\n *\n * const isMfaRequired = true\n *\n * function Component() {\n * const { isLoading, userMeetsMfaRequirement } =\n * useUserMeetsMfaRequirement(isMfaRequired)\n * }\n * ```\n *\n * @returns\n * @group Hooks\n */\nexport function useUserMeetsMfaRequirement(isMfaRequired: boolean) {\n const context = React.useContext(MfaContext)\n\n if (!context) {\n throw new Error(\n `\"useUserMeetsMfaRequirement\" hook was used outside of the \"<MfaProvider />\" component's children.`,\n )\n }\n\n const { isLoading, loadingError, loadMfa, isMfaEnabled } = context\n\n if (!isMfaRequired) {\n return {\n isLoading: false,\n loadingError: undefined,\n userMeetsMfaRequirement: true,\n loadMfa,\n }\n }\n\n return {\n isLoading,\n loadingError,\n loadMfa,\n userMeetsMfaRequirement: isMfaEnabled,\n }\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -27,5 +27,5 @@ export { default as ProgressBar } from './components/renderer/ProgressBar';
27
27
  export { default as PaymentReceipt } from './PaymentReceipt';
28
28
  export { default as PaymentForm } from './components/payments/PaymentForm';
29
29
  export { default as MultiFactorAuthentication } from './components/mfa/MultiFactorAuthentication';
30
- export { AppUserMfaProvider, useUserMeetsMfaRequirement, } from './hooks/useAppUserMfa';
30
+ export { default as useMfa, MfaProvider, useUserMeetsMfaRequirement, } from './hooks/useMfa';
31
31
  export * from './types/form';
package/dist/index.js CHANGED
@@ -27,6 +27,6 @@ export { default as ProgressBar } from './components/renderer/ProgressBar';
27
27
  export { default as PaymentReceipt } from './PaymentReceipt';
28
28
  export { default as PaymentForm } from './components/payments/PaymentForm';
29
29
  export { default as MultiFactorAuthentication } from './components/mfa/MultiFactorAuthentication';
30
- export { AppUserMfaProvider, useUserMeetsMfaRequirement, } from './hooks/useAppUserMfa';
30
+ export { default as useMfa, MfaProvider, useUserMeetsMfaRequirement, } from './hooks/useMfa';
31
31
  export * from './types/form';
32
32
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,wBAAwB,IAAI,YAAY,EACxC,sBAAsB,GACvB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,OAAO,IAAI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0B,CAAA;AACjC,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAChF,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AACxE,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AAClF,OAAO,EAAE,OAAO,IAAI,8BAA8B,EAAE,MAAM,wCAAwC,CAAA;AAClG,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,8BAA8B,CAAA;AAE9E,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAC1E,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAE1E,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,4CAA4C,CAAA;AAEjG,OAAO,EACL,kBAAkB,EAClB,0BAA0B,GAC3B,MAAM,uBAAuB,CAAA;AAE9B,cAAc,cAAc,CAAA","sourcesContent":["export {\n OneBlinkFormBaseProps,\n OneBlinkFormControlledProps,\n OneBlinkFormUncontrolled as OneBlinkForm,\n OneBlinkFormControlled,\n} from './OneBlinkForm'\nexport { default as OneBlinkAutoSaveForm } from './OneBlinkAutoSaveForm'\nexport { default as OneBlinkReadOnlyForm } from './OneBlinkReadOnlyForm'\nexport { OneBlinkFormStoreProvider } from './components/formStore/OneBlinkFormStoreProvider'\nexport { default as OneBlinkFormStoreClearFiltersButton } from './components/formStore/OneBlinkFormStoreClearFiltersButton'\nexport { default as OneBlinkFormStoreColumnsButton } from './components/formStore/OneBlinkFormStoreColumnsButton'\nexport { default as OneBlinkFormStoreDownloadButton } from './components/formStore/OneBlinkFormStoreDownloadButton'\nexport { default as OneBlinkFormStoreRefreshButton } from './components/formStore/OneBlinkFormStoreRefreshButton'\nexport { default as OneBlinkFormStoreTable } from './components/formStore/OneBlinkFormStoreTable'\n\nexport { default as useIsMounted } from './hooks/useIsMounted'\nexport { default as useBooleanState } from './hooks/useBooleanState'\nexport { default as useNullableState } from './hooks/useNullableState'\nexport { default as useClickOutsideElement } from './hooks/useClickOutsideElement'\nexport {\n default as useIsOffline,\n IsOfflineContextProvider,\n} from './hooks/useIsOffline'\nexport { default as useLogin, UseLoginValue } from './hooks/useLogin'\nexport { default as useSignUp } from './hooks/useSignUp'\nexport {\n default as useAuth,\n AuthContextProvider,\n AuthContextValue,\n} from './hooks/useAuth'\nexport {\n default as usePendingSubmissions,\n PendingSubmissionsContextProvider,\n PendingSubmissionsContextValue,\n} from './hooks/usePendingSubmissions'\nexport {\n default as useDrafts,\n DraftsContextProvider,\n DraftsContextValue,\n} from './hooks/useDrafts'\nexport {\n default as useLoadDataState,\n LoadDataState,\n} from './hooks/useLoadDataState'\nexport { default as useLoadResourcesState } from './hooks/useLoadResourcesState'\nexport { default as useLoadDataEffect } from './hooks/useLoadDataEffect'\nexport { default as useFormSubmissionState } from './hooks/useFormSubmissionState'\nexport { default as useFormSubmissionAutoSaveState } from './hooks/useFormSubmissionAutoSaveState'\nexport { default as useGoogleJsApiLoader } from './hooks/useGoogleJsApiLoader'\n\nexport { default as ProgressBar } from './components/renderer/ProgressBar'\nexport { default as PaymentReceipt } from './PaymentReceipt'\nexport { default as PaymentForm } from './components/payments/PaymentForm'\n\nexport { default as MultiFactorAuthentication } from './components/mfa/MultiFactorAuthentication'\n\nexport {\n AppUserMfaProvider,\n useUserMeetsMfaRequirement,\n} from './hooks/useAppUserMfa'\n\nexport * from './types/form'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,wBAAwB,IAAI,YAAY,EACxC,sBAAsB,GACvB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AACxE,OAAO,EAAE,OAAO,IAA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A+B,CAAA;AAChF,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AACxE,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AAClF,OAAO,EAAE,OAAO,IAAI,8BAA8B,EAAE,MAAM,wCAAwC,CAAA;AAClG,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,8BAA8B,CAAA;AAE9E,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAC1E,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAE1E,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,4CAA4C,CAAA;AAEjG,OAAO,EACL,OAAO,IAAI,MAAM,EACjB,WAAW,EACX,0BAA0B,GAC3B,MAAM,gBAAgB,CAAA;AAEvB,cAAc,cAAc,CAAA","sourcesContent":["export {\n OneBlinkFormBaseProps,\n OneBlinkFormControlledProps,\n OneBlinkFormUncontrolled as OneBlinkForm,\n OneBlinkFormControlled,\n} from './OneBlinkForm'\nexport { default as OneBlinkAutoSaveForm } from './OneBlinkAutoSaveForm'\nexport { default as OneBlinkReadOnlyForm } from './OneBlinkReadOnlyForm'\nexport { OneBlinkFormStoreProvider } from './components/formStore/OneBlinkFormStoreProvider'\nexport { default as OneBlinkFormStoreClearFiltersButton } from './components/formStore/OneBlinkFormStoreClearFiltersButton'\nexport { default as OneBlinkFormStoreColumnsButton } from './components/formStore/OneBlinkFormStoreColumnsButton'\nexport { default as OneBlinkFormStoreDownloadButton } from './components/formStore/OneBlinkFormStoreDownloadButton'\nexport { default as OneBlinkFormStoreRefreshButton } from './components/formStore/OneBlinkFormStoreRefreshButton'\nexport { default as OneBlinkFormStoreTable } from './components/formStore/OneBlinkFormStoreTable'\n\nexport { default as useIsMounted } from './hooks/useIsMounted'\nexport { default as useBooleanState } from './hooks/useBooleanState'\nexport { default as useNullableState } from './hooks/useNullableState'\nexport { default as useClickOutsideElement } from './hooks/useClickOutsideElement'\nexport {\n default as useIsOffline,\n IsOfflineContextProvider,\n} from './hooks/useIsOffline'\nexport { default as useLogin, UseLoginValue } from './hooks/useLogin'\nexport { default as useSignUp } from './hooks/useSignUp'\nexport {\n default as useAuth,\n AuthContextProvider,\n AuthContextValue,\n} from './hooks/useAuth'\nexport {\n default as usePendingSubmissions,\n PendingSubmissionsContextProvider,\n PendingSubmissionsContextValue,\n} from './hooks/usePendingSubmissions'\nexport {\n default as useDrafts,\n DraftsContextProvider,\n DraftsContextValue,\n} from './hooks/useDrafts'\nexport {\n default as useLoadDataState,\n LoadDataState,\n} from './hooks/useLoadDataState'\nexport { default as useLoadResourcesState } from './hooks/useLoadResourcesState'\nexport { default as useLoadDataEffect } from './hooks/useLoadDataEffect'\nexport { default as useFormSubmissionState } from './hooks/useFormSubmissionState'\nexport { default as useFormSubmissionAutoSaveState } from './hooks/useFormSubmissionAutoSaveState'\nexport { default as useGoogleJsApiLoader } from './hooks/useGoogleJsApiLoader'\n\nexport { default as ProgressBar } from './components/renderer/ProgressBar'\nexport { default as PaymentReceipt } from './PaymentReceipt'\nexport { default as PaymentForm } from './components/payments/PaymentForm'\n\nexport { default as MultiFactorAuthentication } from './components/mfa/MultiFactorAuthentication'\n\nexport {\n default as useMfa,\n MfaProvider,\n useUserMeetsMfaRequirement,\n} from './hooks/useMfa'\n\nexport * from './types/form'\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oneblink/apps-react",
3
3
  "description": "Helper functions for OneBlink apps in ReactJS.",
4
- "version": "6.10.0-beta.5",
4
+ "version": "6.10.0-beta.7",
5
5
  "author": "OneBlink <developers@oneblink.io> (https://oneblink.io)",
6
6
  "bugs": {
7
7
  "url": "https://github.com/oneblink/apps-react/issues"
@@ -1,7 +0,0 @@
1
- import * as React from 'react';
2
- import { Button } from '@mui/material';
3
- type Props = {
4
- loading: boolean;
5
- } & React.ComponentProps<typeof Button>;
6
- declare const _default: React.MemoExoticComponent<({ loading, color, disabled, ...props }: Props) => React.JSX.Element>;
7
- export default _default;
@@ -1,12 +0,0 @@
1
- import * as React from 'react';
2
- import { CircularProgress, Button } from '@mui/material';
3
- const LoadingButton = ({ loading, color, disabled, ...props }) => {
4
- return (React.createElement(Button, { color: color, disabled: loading || disabled, ...props },
5
- React.createElement(React.Fragment, null,
6
- React.createElement("span", { style: { opacity: loading ? 0 : undefined } }, props.children),
7
- loading && (React.createElement(CircularProgress, { color: color, style: {
8
- position: 'absolute',
9
- }, size: 24 })))));
10
- };
11
- export default React.memo(LoadingButton);
12
- //# sourceMappingURL=LoadingButton.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LoadingButton.js","sourceRoot":"","sources":["../../src/components/LoadingButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAKxD,MAAM,aAAa,GAAG,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAS,EAAE,EAAE;IACtE,OAAO,CACL,oBAAC,MAAM,IAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,IAAI,QAAQ,KAAM,KAAK;QAC5D;YACE,8BAAM,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,IAC9C,KAAK,CAAC,QAAQ,CACV;YACN,OAAO,IAAI,CACV,oBAAC,gBAAgB,IACf,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE;oBACL,QAAQ,EAAE,UAAU;iBACrB,EACD,IAAI,EAAE,EAAE,GACU,CACrB,CACA,CACI,CACV,CAAA;AACH,CAAC,CAAA;AACD,eAAe,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport { CircularProgress, Button } from '@mui/material'\n\ntype Props = {\n loading: boolean\n} & React.ComponentProps<typeof Button>\nconst LoadingButton = ({ loading, color, disabled, ...props }: Props) => {\n return (\n <Button color={color} disabled={loading || disabled} {...props}>\n <>\n <span style={{ opacity: loading ? 0 : undefined }}>\n {props.children}\n </span>\n {loading && (\n <CircularProgress\n color={color}\n style={{\n position: 'absolute',\n }}\n size={24}\n ></CircularProgress>\n )}\n </>\n </Button>\n )\n}\nexport default React.memo(LoadingButton)\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useAppUserMfa.js","sourceRoot":"","sources":["../../src/hooks/useAppUserMfa.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAY5C,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC,aAAa,CAWlD;IACA,SAAS,EAAE,IAAI;IACf,YAAY,EAAE,KAAK;IACnB,cAAc,EAAE,KAAK;IACrB,cAAc,EAAE,KAAK;IACrB,aAAa,EAAE,GAAG,EAAE,GAAE,CAAC;IACvB,cAAc,EAAE,GAAG,EAAE,GAAE,CAAC;IACxB,gBAAgB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC1B,iBAAiB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC3B,kBAAkB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC5B,oBAAoB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC9B,kBAAkB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC5B,cAAc,EAAE,GAAG,EAAE,GAAE,CAAC;CACzB,CAAC,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,UAAU,kBAAkB,CAAC,EACjC,QAAQ,EACR,8BAA8B,GAI/B;IACC,M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AA;IAEF,OAAO,CACL,oBAAC,iBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IACrC,QAAQ,CACkB,CAC9B,CAAA;AACH,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,aAAa;IACnC,OAAO,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAA;AAC5C,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,0BAA0B,CAAC,oBAA6B;IACtE,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAA;IAEnD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,0GAA0G,CAC3G,CAAA;IACH,CAAC;IAED,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,GAAG,OAAO,CAAA;IAEzE,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC1B,OAAO;YACL,SAAS,EAAE,KAAK;YAChB,YAAY,EAAE,SAAS;YACvB,uBAAuB,EAAE,IAAI;YAC7B,cAAc;SACf,CAAA;IACH,CAAC;IAED,OAAO;QACL,SAAS;QACT,YAAY;QACZ,cAAc;QACd,uBAAuB,EAAE,YAAY;KACtC,CAAA;AACH,CAAC","sourcesContent":["import * as React from 'react'\nimport { authService } from '@oneblink/apps'\n\ntype AppUserMfaState = {\n isLoading: boolean\n isMfaEnabled: boolean\n loadingError?: Error\n isSettingUpMfa: boolean\n isDisablingMfa: boolean\n setupError?: Error\n mfaSetup?: Awaited<ReturnType<typeof authService.setupMfa>>\n}\n\nexport const AppUserMfaContext = React.createContext<\n AppUserMfaState & {\n beginMfaSetup: () => void\n cancelMfaSetup: () => void\n completeMfaSetup: () => void\n beginDisablingMfa: () => void\n cancelDisablingMfa: () => void\n completeDisablingMfa: () => void\n clearMfaSetupError: () => void\n loadAppUserMfa: () => void\n }\n>({\n isLoading: true,\n isMfaEnabled: false,\n isSettingUpMfa: false,\n isDisablingMfa: false,\n beginMfaSetup: () => {},\n cancelMfaSetup: () => {},\n completeMfaSetup: () => {},\n beginDisablingMfa: () => {},\n cancelDisablingMfa: () => {},\n completeDisablingMfa: () => {},\n clearMfaSetupError: () => {},\n loadAppUserMfa: () => {},\n})\n\n/**\n * React Component that provides the context for the\n * `useUserMeetsMfaRequirement()` hook and `<MultiFactorAuthentication />`\n * component, to be used by components further down your component tree. **It\n * should only be included in your component tree once and ideally at the root\n * of the application.**\n *\n * #### Example\n *\n * ```js\n * import * as React from 'react'\n * import {\n * AppUserMfaProvider,\n * useUserMeetsMfaRequirement,\n * } from '@oneblink/apps-react'\n *\n * function Component() {\n * const { isLoading, userMeetsMfaRequirement } =\n * useUserMeetsMfaRequirement(true)\n * // use App User MFA Requirement details here\n * }\n *\n * function App() {\n * return (\n * <AppUserMfaProvider isExternalIdentityProviderUser={false}>\n * <Component />\n * </AppUserMfaProvider>\n * )\n * }\n *\n * const root = document.getElementById('root')\n * if (root) {\n * ReactDOM.render(<App />, root)\n * }\n * ```\n *\n * @param props\n * @returns\n * @group Components\n */\nexport function AppUserMfaProvider({\n children,\n isExternalIdentityProviderUser,\n}: {\n children: React.ReactNode\n isExternalIdentityProviderUser: boolean\n}) {\n const [state, setState] = React.useState<AppUserMfaState>({\n isLoading: !isExternalIdentityProviderUser,\n isMfaEnabled: false,\n isSettingUpMfa: false,\n isDisablingMfa: false,\n })\n\n const loadAppUserMfa = React.useCallback(\n async (abortSignal?: AbortSignal) => {\n setState((currentState) => ({\n ...currentState,\n isLoading: true,\n isMfaEnabled: false,\n loadingError: undefined,\n }))\n try {\n const newIsMfaEnabled = await authService.checkIsMfaEnabled()\n if (!abortSignal?.aborted) {\n setState((currentState) => ({\n ...currentState,\n isLoading: false,\n isMfaEnabled: newIsMfaEnabled,\n }))\n }\n } catch (error) {\n setState((currentState) => ({\n ...currentState,\n isLoading: false,\n loadingError: error as Error,\n }))\n }\n },\n [],\n )\n\n const clearMfaSetupError = React.useCallback(() => {\n setState((currentState) => ({\n ...currentState,\n setupError: undefined,\n }))\n }, [])\n\n const cancelMfaSetup = React.useCallback(() => {\n setState((currentState) => ({\n ...currentState,\n mfaSetup: undefined,\n }))\n }, [])\n\n const completeMfaSetup = React.useCallback(() => {\n setState((currentState) => ({\n ...currentState,\n isMfaEnabled: true,\n mfaSetup: undefined,\n }))\n }, [])\n\n const beginMfaSetup = React.useCallback(async () => {\n setState((currentState) => ({\n ...currentState,\n isSettingUpMfa: true,\n mfaSetup: undefined,\n setupError: undefined,\n }))\n try {\n const newMfaSetup = await authService.setupMfa()\n setState((currentState) => ({\n ...currentState,\n isSettingUpMfa: false,\n mfaSetup: newMfaSetup,\n }))\n } catch (error) {\n setState((currentState) => ({\n ...currentState,\n isSettingUpMfa: false,\n setupError: error as Error,\n }))\n }\n }, [])\n\n const beginDisablingMfa = React.useCallback(() => {\n setState((currentState) => ({\n ...currentState,\n isDisablingMfa: true,\n }))\n }, [])\n\n const cancelDisablingMfa = React.useCallback(() => {\n setState((currentState) => ({\n ...currentState,\n isDisablingMfa: false,\n }))\n }, [])\n\n const completeDisablingMfa = React.useCallback(async () => {\n await authService.disableMfa()\n setState((currentState) => ({\n ...currentState,\n isDisablingMfa: false,\n isMfaEnabled: false,\n }))\n }, [])\n\n React.useEffect(() => {\n if (isExternalIdentityProviderUser) {\n return\n }\n\n loadAppUserMfa()\n\n return () => {}\n }, [isExternalIdentityProviderUser, loadAppUserMfa])\n\n const value = React.useMemo(() => {\n return {\n ...state,\n clearMfaSetupError,\n loadAppUserMfa,\n beginMfaSetup,\n cancelMfaSetup,\n completeMfaSetup,\n beginDisablingMfa,\n cancelDisablingMfa,\n completeDisablingMfa,\n }\n }, [\n state,\n clearMfaSetupError,\n loadAppUserMfa,\n beginMfaSetup,\n cancelMfaSetup,\n completeMfaSetup,\n beginDisablingMfa,\n cancelDisablingMfa,\n completeDisablingMfa,\n ])\n\n return (\n <AppUserMfaContext.Provider value={value}>\n {children}\n </AppUserMfaContext.Provider>\n )\n}\n\nexport default function useAppUserMfa() {\n return React.useContext(AppUserMfaContext)\n}\n\n/**\n * React hook to get the state associated to the logged in user's MFA status.\n * Will throw an Error if used outside of the `<AppUserMfaProvider />`\n * component.\n *\n * Example\n *\n * ```js\n * import { useUserMeetsMfaRequirement } from '@oneblink/apps-react'\n *\n * const isAppUserMfaRequired = true\n *\n * function Component() {\n * const { isLoading, userMeetsMfaRequirement } =\n * useUserMeetsMfaRequirement(isAppUserMfaRequired)\n * }\n * ```\n *\n * @returns\n * @group Hooks\n */\nexport function useUserMeetsMfaRequirement(isAppUserMfaRequired: boolean) {\n const context = React.useContext(AppUserMfaContext)\n\n if (!context) {\n throw new Error(\n `\"useUserMeetsMfaRequirement\" hook was used outside of the \"<AppUserMfaProvider />\" component's children.`,\n )\n }\n\n const { isLoading, loadingError, loadAppUserMfa, isMfaEnabled } = context\n\n if (!isAppUserMfaRequired) {\n return {\n isLoading: false,\n loadingError: undefined,\n userMeetsMfaRequirement: true,\n loadAppUserMfa,\n }\n }\n\n return {\n isLoading,\n loadingError,\n loadAppUserMfa,\n userMeetsMfaRequirement: isMfaEnabled,\n }\n}\n"]}