@aws-amplify/ui-react-native 1.2.28 → 2.0.1
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.
- package/dist/Authenticator/Authenticator.d.ts +83 -12
- package/dist/Authenticator/Authenticator.js +19 -16
- package/dist/Authenticator/Defaults/{ResetPassword/ResetPassword.d.ts → ForgotPassword/ForgotPassword.d.ts} +4 -4
- package/dist/Authenticator/Defaults/{ResetPassword/ResetPassword.js → ForgotPassword/ForgotPassword.js} +7 -7
- package/dist/Authenticator/Defaults/ForgotPassword/index.d.ts +1 -0
- package/dist/Authenticator/Defaults/ForgotPassword/index.js +1 -0
- package/dist/Authenticator/Defaults/{SetupTOTP/SetupTOTP.d.ts → SetupTotp/SetupTotp.d.ts} +4 -4
- package/dist/Authenticator/Defaults/{SetupTOTP/SetupTOTP.js → SetupTotp/SetupTotp.js} +10 -10
- package/dist/Authenticator/Defaults/SetupTotp/index.d.ts +1 -0
- package/dist/Authenticator/Defaults/SetupTotp/index.js +1 -0
- package/dist/Authenticator/Defaults/SetupTotp/styles.d.ts +5 -0
- package/dist/Authenticator/Defaults/SignIn/SignIn.d.ts +1 -1
- package/dist/Authenticator/Defaults/SignIn/SignIn.js +6 -5
- package/dist/Authenticator/Defaults/SignUp/SignUp.d.ts +1 -1
- package/dist/Authenticator/Defaults/SignUp/SignUp.js +4 -3
- package/dist/Authenticator/Defaults/index.d.ts +2 -2
- package/dist/Authenticator/Defaults/index.js +2 -2
- package/dist/Authenticator/Defaults/types.d.ts +13 -13
- package/dist/Authenticator/common/FederatedProviderButton/FederatedProviderButton.js +2 -4
- package/dist/Authenticator/common/FederatedProviderButton/types.d.ts +3 -1
- package/dist/Authenticator/common/FederatedProviderButtons/FederatedProviderButtons.d.ts +1 -1
- package/dist/Authenticator/common/FederatedProviderButtons/FederatedProviderButtons.js +24 -11
- package/dist/Authenticator/common/FederatedProviderButtons/styles.d.ts +2 -1
- package/dist/Authenticator/common/FederatedProviderButtons/styles.js +14 -4
- package/dist/Authenticator/common/FederatedProviderButtons/types.d.ts +5 -3
- package/dist/Authenticator/hooks/useFieldValues/useFieldValues.js +1 -1
- package/dist/Authenticator/hooks/useFieldValues/utils.js +1 -1
- package/dist/Authenticator/types.d.ts +1 -1
- package/dist/InAppMessaging/components/InAppMessageDisplay/handleMessageLinkAction.js +2 -2
- package/dist/InAppMessaging/hooks/useMessageImage/useMessageImage.d.ts +2 -2
- package/dist/InAppMessaging/hooks/useMessageImage/useMessageImage.js +2 -2
- package/dist/InAppMessaging/hooks/useMessageImage/utils.d.ts +2 -2
- package/dist/InAppMessaging/hooks/useMessageImage/utils.js +2 -2
- package/dist/InAppMessaging/hooks/useMessageProps/types.d.ts +2 -2
- package/dist/InAppMessaging/hooks/useMessageProps/utils.d.ts +2 -2
- package/dist/InAppMessaging/index.d.ts +1 -1
- package/dist/InAppMessaging/index.js +1 -0
- package/dist/assets/icons/icons.ts +3 -0
- package/dist/primitives/Button/styles.js +4 -2
- package/dist/primitives/Carousel/Carousel.js +1 -11
- package/dist/primitives/Divider/styles.js +4 -3
- package/dist/primitives/ErrorMessage/ErrorMessage.d.ts +1 -1
- package/dist/primitives/ErrorMessage/ErrorMessage.js +2 -2
- package/dist/primitives/Icon/Icon.d.ts +1 -1
- package/dist/primitives/Icon/Icon.js +2 -1
- package/dist/primitives/Icon/styles.js +1 -1
- package/dist/primitives/Radio/styles.js +1 -1
- package/dist/primitives/RadioGroup/RadioGroup.d.ts +1 -1
- package/dist/primitives/RadioGroup/RadioGroup.js +2 -2
- package/dist/primitives/Tabs/Tabs.d.ts +1 -1
- package/dist/primitives/Tabs/Tabs.js +2 -2
- package/dist/primitives/Tabs/styles.js +3 -3
- package/dist/utils/platform.d.ts +1 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/lib/Authenticator/Authenticator.js +17 -14
- package/lib/Authenticator/Defaults/{ResetPassword/ResetPassword.js → ForgotPassword/ForgotPassword.js} +7 -7
- package/lib/Authenticator/Defaults/ForgotPassword/index.js +8 -0
- package/lib/Authenticator/Defaults/{SetupTOTP/SetupTOTP.js → SetupTotp/SetupTotp.js} +10 -10
- package/lib/Authenticator/Defaults/{SetupTOTP → SetupTotp}/index.js +3 -3
- package/lib/Authenticator/Defaults/SignIn/SignIn.js +5 -4
- package/lib/Authenticator/Defaults/SignUp/SignUp.js +3 -2
- package/lib/Authenticator/Defaults/index.js +5 -5
- package/lib/Authenticator/common/FederatedProviderButton/FederatedProviderButton.js +2 -4
- package/lib/Authenticator/common/FederatedProviderButtons/FederatedProviderButtons.js +22 -9
- package/lib/Authenticator/common/FederatedProviderButtons/styles.js +16 -5
- package/lib/Authenticator/hooks/useFieldValues/useFieldValues.js +8 -8
- package/lib/Authenticator/hooks/useFieldValues/utils.js +2 -2
- package/lib/InAppMessaging/components/InAppMessageDisplay/handleMessageLinkAction.js +2 -2
- package/lib/InAppMessaging/hooks/useMessageImage/types.js +1 -1
- package/lib/InAppMessaging/hooks/useMessageImage/useMessageImage.js +5 -5
- package/lib/InAppMessaging/hooks/useMessageImage/utils.js +2 -2
- package/lib/InAppMessaging/index.js +1 -0
- package/lib/assets/icons/icons.ts +3 -0
- package/lib/primitives/Button/styles.js +4 -2
- package/lib/primitives/Carousel/Carousel.js +1 -11
- package/lib/primitives/Divider/styles.js +4 -3
- package/lib/primitives/ErrorMessage/ErrorMessage.js +2 -2
- package/lib/primitives/Icon/Icon.js +2 -1
- package/lib/primitives/Icon/styles.js +2 -2
- package/lib/primitives/Radio/styles.js +1 -1
- package/lib/primitives/RadioGroup/RadioGroup.js +2 -2
- package/lib/primitives/Tabs/Tabs.js +2 -2
- package/lib/primitives/Tabs/styles.js +3 -3
- package/lib/version.js +1 -1
- package/package.json +16 -31
- package/src/Authenticator/Authenticator.tsx +20 -17
- package/src/Authenticator/Defaults/{ResetPassword/ResetPassword.tsx → ForgotPassword/ForgotPassword.tsx} +9 -9
- package/src/Authenticator/Defaults/ForgotPassword/index.ts +1 -0
- package/src/Authenticator/Defaults/{SetupTOTP/SetupTOTP.tsx → SetupTotp/SetupTotp.tsx} +13 -13
- package/src/Authenticator/Defaults/SetupTotp/index.ts +1 -0
- package/src/Authenticator/Defaults/{SetupTOTP → SetupTotp}/styles.ts +2 -2
- package/src/Authenticator/Defaults/SignIn/SignIn.tsx +15 -3
- package/src/Authenticator/Defaults/SignUp/SignUp.tsx +12 -0
- package/src/Authenticator/Defaults/index.ts +2 -2
- package/src/Authenticator/Defaults/types.ts +15 -15
- package/src/Authenticator/common/FederatedProviderButton/FederatedProviderButton.tsx +2 -4
- package/src/Authenticator/common/FederatedProviderButton/types.ts +3 -1
- package/src/Authenticator/common/FederatedProviderButtons/FederatedProviderButtons.tsx +41 -13
- package/src/Authenticator/common/FederatedProviderButtons/styles.ts +19 -4
- package/src/Authenticator/common/FederatedProviderButtons/types.ts +9 -6
- package/src/Authenticator/hooks/useFieldValues/useFieldValues.ts +1 -1
- package/src/Authenticator/hooks/useFieldValues/utils.ts +1 -1
- package/src/Authenticator/types.ts +1 -4
- package/src/InAppMessaging/components/InAppMessageDisplay/handleMessageLinkAction.ts +2 -2
- package/src/InAppMessaging/hooks/useMessageImage/useMessageImage.ts +6 -6
- package/src/InAppMessaging/hooks/useMessageImage/utils.ts +5 -5
- package/src/InAppMessaging/hooks/useMessageProps/types.ts +3 -3
- package/src/InAppMessaging/hooks/useMessageProps/utils.ts +2 -2
- package/src/InAppMessaging/index.ts +9 -0
- package/src/assets/icons/icons.ts +3 -0
- package/src/hooks/useDeviceOrientation/useDeviceOrientation.ts +6 -1
- package/src/primitives/Button/styles.ts +4 -2
- package/src/primitives/Carousel/Carousel.tsx +1 -10
- package/src/primitives/Divider/styles.ts +4 -3
- package/src/primitives/ErrorMessage/ErrorMessage.tsx +4 -1
- package/src/primitives/Icon/Icon.tsx +2 -0
- package/src/primitives/Icon/styles.ts +1 -1
- package/src/primitives/Radio/styles.ts +1 -1
- package/src/primitives/RadioGroup/RadioGroup.tsx +6 -1
- package/src/primitives/Tabs/Tabs.tsx +4 -1
- package/src/primitives/Tabs/styles.ts +3 -3
- package/src/version.ts +1 -1
- package/dist/Authenticator/Defaults/ResetPassword/index.d.ts +0 -1
- package/dist/Authenticator/Defaults/ResetPassword/index.js +0 -1
- package/dist/Authenticator/Defaults/SetupTOTP/index.d.ts +0 -1
- package/dist/Authenticator/Defaults/SetupTOTP/index.js +0 -1
- package/dist/Authenticator/Defaults/SetupTOTP/styles.d.ts +0 -5
- package/dist/Authenticator/common/FederatedProviderButton/styles.d.ts +0 -2
- package/dist/Authenticator/common/FederatedProviderButton/styles.js +0 -18
- package/lib/Authenticator/Defaults/ResetPassword/index.js +0 -8
- package/lib/Authenticator/common/FederatedProviderButton/styles.js +0 -21
- package/src/Authenticator/Defaults/ResetPassword/index.ts +0 -1
- package/src/Authenticator/Defaults/SetupTOTP/index.ts +0 -1
- package/src/Authenticator/common/FederatedProviderButton/styles.ts +0 -21
- /package/dist/Authenticator/Defaults/{SetupTOTP → SetupTotp}/styles.js +0 -0
- /package/lib/Authenticator/Defaults/{SetupTOTP → SetupTotp}/styles.js +0 -0
|
@@ -8,10 +8,9 @@ import {
|
|
|
8
8
|
useAuthenticator,
|
|
9
9
|
useAuthenticatorRoute,
|
|
10
10
|
useAuthenticatorInitMachine,
|
|
11
|
+
useSetUserAgent,
|
|
11
12
|
} from '@aws-amplify/ui-react-core';
|
|
12
13
|
|
|
13
|
-
import { configureComponent } from '@aws-amplify/ui';
|
|
14
|
-
|
|
15
14
|
import { useDeprecationWarning } from '../hooks';
|
|
16
15
|
import { DefaultContainer, InnerContainer } from './common';
|
|
17
16
|
import { TypedField, getRouteTypedFields } from './hooks';
|
|
@@ -24,8 +23,8 @@ import {
|
|
|
24
23
|
ConfirmSignUp,
|
|
25
24
|
ConfirmVerifyUser,
|
|
26
25
|
ForceNewPassword,
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
ForgotPassword,
|
|
27
|
+
SetupTotp,
|
|
29
28
|
SignIn,
|
|
30
29
|
SignUp,
|
|
31
30
|
VerifyUser,
|
|
@@ -37,8 +36,8 @@ const DEFAULTS = {
|
|
|
37
36
|
ConfirmSignUp,
|
|
38
37
|
ConfirmVerifyUser,
|
|
39
38
|
ForceNewPassword,
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
ForgotPassword,
|
|
40
|
+
SetupTotp,
|
|
42
41
|
SignIn,
|
|
43
42
|
SignUp,
|
|
44
43
|
VerifyUser,
|
|
@@ -61,19 +60,22 @@ function Authenticator({
|
|
|
61
60
|
useDeprecationWarning({
|
|
62
61
|
message:
|
|
63
62
|
'The `passwordSettings` prop has been deprecated and will be removed in a future major version of Amplify UI.',
|
|
64
|
-
shouldWarn: !!options?.passwordSettings,
|
|
63
|
+
// shouldWarn: !!options?.passwordSettings,
|
|
64
|
+
/**
|
|
65
|
+
* @migration turn off until getConfig returns zero config
|
|
66
|
+
*/
|
|
67
|
+
shouldWarn: false,
|
|
65
68
|
});
|
|
66
69
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}, []);
|
|
70
|
+
useSetUserAgent({
|
|
71
|
+
componentName: 'Authenticator',
|
|
72
|
+
packageName: 'react-native',
|
|
73
|
+
version: VERSION,
|
|
74
|
+
});
|
|
73
75
|
|
|
74
76
|
useAuthenticatorInitMachine(options);
|
|
75
77
|
|
|
76
|
-
const {
|
|
78
|
+
const { fields, route } = useAuthenticator(routePropSelector);
|
|
77
79
|
|
|
78
80
|
const components = useMemo(
|
|
79
81
|
// allow any to prevent TS from assuming that all fields are of type `TextFieldOptions`
|
|
@@ -84,8 +86,9 @@ function Authenticator({
|
|
|
84
86
|
const { Component, props } = useAuthenticatorRoute({ components });
|
|
85
87
|
|
|
86
88
|
const typedFields = getRouteTypedFields({ fields, route });
|
|
89
|
+
const isAuthenticatedRoute = route === 'authenticated' || route === 'signOut';
|
|
87
90
|
|
|
88
|
-
if (
|
|
91
|
+
if (isAuthenticatedRoute) {
|
|
89
92
|
return children ? <>{children}</> : null;
|
|
90
93
|
}
|
|
91
94
|
|
|
@@ -110,8 +113,8 @@ Authenticator.ConfirmSignIn = ConfirmSignIn;
|
|
|
110
113
|
Authenticator.ConfirmSignUp = ConfirmSignUp;
|
|
111
114
|
Authenticator.ConfirmVerifyUser = ConfirmVerifyUser;
|
|
112
115
|
Authenticator.ForceNewPassword = ForceNewPassword;
|
|
113
|
-
Authenticator.
|
|
114
|
-
Authenticator.
|
|
116
|
+
Authenticator.ForgotPassword = ForgotPassword;
|
|
117
|
+
Authenticator.SetupTotp = SetupTotp;
|
|
115
118
|
Authenticator.SignIn = SignIn;
|
|
116
119
|
Authenticator.SignUp = SignUp;
|
|
117
120
|
Authenticator.VerifyUser = VerifyUser;
|
|
@@ -9,9 +9,9 @@ import {
|
|
|
9
9
|
} from '../../common';
|
|
10
10
|
import { useFieldValues } from '../../hooks';
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { DefaultForgotPasswordProps } from '../types';
|
|
13
13
|
|
|
14
|
-
const COMPONENT_NAME = '
|
|
14
|
+
const COMPONENT_NAME = 'ForgotPassword';
|
|
15
15
|
const {
|
|
16
16
|
getResetYourPasswordText,
|
|
17
17
|
getSendCodeText,
|
|
@@ -19,7 +19,7 @@ const {
|
|
|
19
19
|
getBackToSignInText,
|
|
20
20
|
} = authenticatorTextUtil;
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
const ForgotPassword = ({
|
|
23
23
|
fields,
|
|
24
24
|
handleBlur,
|
|
25
25
|
handleChange,
|
|
@@ -28,7 +28,7 @@ const ResetPassword = ({
|
|
|
28
28
|
toSignIn,
|
|
29
29
|
validationErrors,
|
|
30
30
|
...rest
|
|
31
|
-
}:
|
|
31
|
+
}: DefaultForgotPasswordProps): JSX.Element => {
|
|
32
32
|
const {
|
|
33
33
|
disableFormSubmit: disabled,
|
|
34
34
|
fields: fieldsWithHandlers,
|
|
@@ -77,9 +77,9 @@ const ResetPassword = ({
|
|
|
77
77
|
);
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
ForgotPassword.Footer = DefaultFooter;
|
|
81
|
+
ForgotPassword.FormFields = DefaultTextFormFields;
|
|
82
|
+
ForgotPassword.Header = DefaultHeader;
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
export default
|
|
84
|
+
ForgotPassword.displayName = COMPONENT_NAME;
|
|
85
|
+
export default ForgotPassword;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ForgotPassword } from './ForgotPassword';
|
|
@@ -12,20 +12,20 @@ import {
|
|
|
12
12
|
} from '../../common';
|
|
13
13
|
import { useFieldValues } from '../../hooks';
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { DefaultSetupTotpProps } from '../types';
|
|
16
16
|
import { styles } from './styles';
|
|
17
17
|
|
|
18
|
-
const COMPONENT_NAME = '
|
|
18
|
+
const COMPONENT_NAME = 'SetupTotp';
|
|
19
19
|
|
|
20
20
|
const {
|
|
21
21
|
getBackToSignInText,
|
|
22
22
|
getConfirmingText,
|
|
23
23
|
getConfirmText,
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
getSetupTotpText,
|
|
25
|
+
getSetupTotpInstructionsText,
|
|
26
26
|
} = authenticatorTextUtil;
|
|
27
27
|
|
|
28
|
-
const
|
|
28
|
+
const SetupTotp = ({
|
|
29
29
|
fields,
|
|
30
30
|
handleBlur,
|
|
31
31
|
handleChange,
|
|
@@ -35,7 +35,7 @@ const SetupTOTP = ({
|
|
|
35
35
|
totpSecretCode,
|
|
36
36
|
validationErrors,
|
|
37
37
|
...rest
|
|
38
|
-
}:
|
|
38
|
+
}: DefaultSetupTotpProps): JSX.Element => {
|
|
39
39
|
const {
|
|
40
40
|
disableFormSubmit: disabled,
|
|
41
41
|
fields: fieldsWithHandlers,
|
|
@@ -50,14 +50,14 @@ const SetupTOTP = ({
|
|
|
50
50
|
validationErrors,
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
const headerText =
|
|
53
|
+
const headerText = getSetupTotpText();
|
|
54
54
|
const primaryButtonText = isPending ? getConfirmingText() : getConfirmText();
|
|
55
55
|
const secondaryButtonText = getBackToSignInText();
|
|
56
56
|
|
|
57
57
|
const body = (
|
|
58
58
|
<>
|
|
59
59
|
<Label style={styles.secretKeyText}>
|
|
60
|
-
{
|
|
60
|
+
{getSetupTotpInstructionsText()}
|
|
61
61
|
</Label>
|
|
62
62
|
<Label selectable style={styles.secretKeyText}>
|
|
63
63
|
{totpSecretCode}
|
|
@@ -96,9 +96,9 @@ const SetupTOTP = ({
|
|
|
96
96
|
);
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
SetupTotp.Footer = DefaultFooter;
|
|
100
|
+
SetupTotp.FormFields = DefaultTextFormFields;
|
|
101
|
+
SetupTotp.Header = DefaultHeader;
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
export default
|
|
103
|
+
SetupTotp.displayName = COMPONENT_NAME;
|
|
104
|
+
export default SetupTotp;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as SetupTotp } from './SetupTotp';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { StyleSheet, TextStyle } from 'react-native';
|
|
2
2
|
|
|
3
|
-
export interface
|
|
3
|
+
export interface SetupTotpStyle {
|
|
4
4
|
secretKeyText: TextStyle;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
export const styles:
|
|
7
|
+
export const styles: SetupTotpStyle = StyleSheet.create({
|
|
8
8
|
// TODO: replace with tokens
|
|
9
9
|
secretKeyText: { flexWrap: 'wrap', paddingVertical: 4, marginHorizontal: 8 },
|
|
10
10
|
});
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
DefaultTextFormFields,
|
|
7
7
|
DefaultHeader,
|
|
8
8
|
DefaultContent,
|
|
9
|
+
FederatedProviderButtons,
|
|
9
10
|
} from '../../common';
|
|
10
11
|
import { useFieldValues } from '../../hooks';
|
|
11
12
|
|
|
@@ -19,7 +20,9 @@ const SignIn = ({
|
|
|
19
20
|
handleChange,
|
|
20
21
|
handleSubmit,
|
|
21
22
|
hideSignUp,
|
|
22
|
-
|
|
23
|
+
socialProviders,
|
|
24
|
+
toFederatedSignIn,
|
|
25
|
+
toForgotPassword,
|
|
23
26
|
toSignUp,
|
|
24
27
|
validationErrors,
|
|
25
28
|
...rest
|
|
@@ -50,10 +53,18 @@ const SignIn = ({
|
|
|
50
53
|
const signInText = getSignInText();
|
|
51
54
|
const signUpText = getSignUpTabText();
|
|
52
55
|
|
|
56
|
+
const body = socialProviders ? (
|
|
57
|
+
<FederatedProviderButtons
|
|
58
|
+
route="signIn"
|
|
59
|
+
socialProviders={socialProviders}
|
|
60
|
+
toFederatedSignIn={toFederatedSignIn}
|
|
61
|
+
/>
|
|
62
|
+
) : null;
|
|
63
|
+
|
|
53
64
|
const buttons = useMemo(() => {
|
|
54
65
|
const forgotPassword = {
|
|
55
66
|
children: forgotPasswordText,
|
|
56
|
-
onPress:
|
|
67
|
+
onPress: toForgotPassword,
|
|
57
68
|
};
|
|
58
69
|
return {
|
|
59
70
|
primary: { children: signInText, disabled, onPress: handleFormSubmit },
|
|
@@ -68,13 +79,14 @@ const SignIn = ({
|
|
|
68
79
|
hideSignUp,
|
|
69
80
|
signInText,
|
|
70
81
|
signUpText,
|
|
71
|
-
|
|
82
|
+
toForgotPassword,
|
|
72
83
|
toSignUp,
|
|
73
84
|
]);
|
|
74
85
|
|
|
75
86
|
return (
|
|
76
87
|
<DefaultContent
|
|
77
88
|
{...rest}
|
|
89
|
+
body={body}
|
|
78
90
|
buttons={buttons}
|
|
79
91
|
fields={fieldsWithHandlers}
|
|
80
92
|
headerText={headerText}
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
DefaultFooter,
|
|
7
7
|
DefaultTextFormFields,
|
|
8
8
|
DefaultHeader,
|
|
9
|
+
FederatedProviderButtons,
|
|
9
10
|
} from '../../common';
|
|
10
11
|
import { useFieldValues } from '../../hooks';
|
|
11
12
|
|
|
@@ -28,6 +29,8 @@ const SignUp = ({
|
|
|
28
29
|
hasValidationErrors,
|
|
29
30
|
hideSignIn,
|
|
30
31
|
isPending,
|
|
32
|
+
socialProviders,
|
|
33
|
+
toFederatedSignIn,
|
|
31
34
|
toSignIn,
|
|
32
35
|
validationErrors,
|
|
33
36
|
...rest
|
|
@@ -53,6 +56,14 @@ const SignUp = ({
|
|
|
53
56
|
: getCreateAccountText();
|
|
54
57
|
const secondaryButtonText = getSignInTabText();
|
|
55
58
|
|
|
59
|
+
const body = socialProviders ? (
|
|
60
|
+
<FederatedProviderButtons
|
|
61
|
+
route="signUp"
|
|
62
|
+
socialProviders={socialProviders}
|
|
63
|
+
toFederatedSignIn={toFederatedSignIn}
|
|
64
|
+
/>
|
|
65
|
+
) : null;
|
|
66
|
+
|
|
56
67
|
const buttons = useMemo(
|
|
57
68
|
() => ({
|
|
58
69
|
primary: {
|
|
@@ -77,6 +88,7 @@ const SignUp = ({
|
|
|
77
88
|
return (
|
|
78
89
|
<DefaultContent
|
|
79
90
|
{...rest}
|
|
91
|
+
body={body}
|
|
80
92
|
buttons={buttons}
|
|
81
93
|
fields={fieldsWithHandlers}
|
|
82
94
|
headerText={headerText}
|
|
@@ -3,8 +3,8 @@ export { ConfirmSignIn } from './ConfirmSignIn';
|
|
|
3
3
|
export { ConfirmSignUp } from './ConfirmSignUp';
|
|
4
4
|
export { ConfirmVerifyUser } from './ConfirmVerifyUser';
|
|
5
5
|
export { ForceNewPassword } from './ForceNewPassword';
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
6
|
+
export { ForgotPassword } from './ForgotPassword';
|
|
7
|
+
export { SetupTotp } from './SetupTotp';
|
|
8
8
|
export { SignIn } from './SignIn';
|
|
9
9
|
export { SignUp } from './SignUp';
|
|
10
10
|
export { VerifyUser } from './VerifyUser';
|
|
@@ -11,14 +11,14 @@ export interface ConfirmSignUpStyle {}
|
|
|
11
11
|
export interface ConfirmVerifyUserStyle {}
|
|
12
12
|
export interface ForceNewPasswordStyle {}
|
|
13
13
|
export interface ResetPasswordStyle {}
|
|
14
|
-
export interface
|
|
14
|
+
export interface SetupTotpStyle {}
|
|
15
15
|
export interface SignInStyle {}
|
|
16
16
|
export interface SignUpStyle {}
|
|
17
17
|
export interface VerifyUserStyle {}
|
|
18
18
|
|
|
19
19
|
export type DefaultComponents<
|
|
20
20
|
FieldType = {},
|
|
21
|
-
Props = {}
|
|
21
|
+
Props = {},
|
|
22
22
|
> = AuthenticatorComponentDefaults<FieldType, Props>;
|
|
23
23
|
|
|
24
24
|
export type DefaultConfirmResetPasswordProps = React.ComponentPropsWithoutRef<
|
|
@@ -56,18 +56,18 @@ export type DefaultForceNewPasswordProps = React.ComponentPropsWithoutRef<
|
|
|
56
56
|
>['ForceNewPassword']
|
|
57
57
|
>;
|
|
58
58
|
|
|
59
|
-
export type
|
|
59
|
+
export type DefaultForgotPasswordProps = React.ComponentPropsWithoutRef<
|
|
60
60
|
DefaultComponents<
|
|
61
61
|
TextFieldOptionsType,
|
|
62
62
|
{ style?: ResetPasswordStyle }
|
|
63
|
-
>['
|
|
63
|
+
>['ForgotPassword']
|
|
64
64
|
>;
|
|
65
65
|
|
|
66
|
-
export type
|
|
66
|
+
export type DefaultSetupTotpProps = React.ComponentPropsWithoutRef<
|
|
67
67
|
DefaultComponents<
|
|
68
68
|
TextFieldOptionsType,
|
|
69
|
-
{ style?:
|
|
70
|
-
>['
|
|
69
|
+
{ style?: SetupTotpStyle }
|
|
70
|
+
>['SetupTotp']
|
|
71
71
|
>;
|
|
72
72
|
|
|
73
73
|
export type DefaultSignInProps = React.ComponentPropsWithoutRef<
|
|
@@ -90,7 +90,7 @@ export type DefaultVerifyUserProps = React.ComponentPropsWithoutRef<
|
|
|
90
90
|
*/
|
|
91
91
|
type OverrideComponents<
|
|
92
92
|
FieldType = {},
|
|
93
|
-
Props = {}
|
|
93
|
+
Props = {},
|
|
94
94
|
> = AuthenticatorComponentOverrides<FieldType, Props>;
|
|
95
95
|
|
|
96
96
|
type ConfirmSignInComponent<P = {}> = OverrideComponents<
|
|
@@ -118,15 +118,15 @@ type ForceNewPasswordComponent<P = {}> = OverrideComponents<
|
|
|
118
118
|
{ style?: ForceNewPasswordStyle } & P
|
|
119
119
|
>['ForceNewPassword'];
|
|
120
120
|
|
|
121
|
-
type
|
|
121
|
+
type ForgotPasswordComponent<P = {}> = OverrideComponents<
|
|
122
122
|
TextFieldOptionsType,
|
|
123
123
|
{ style?: ResetPasswordStyle } & P
|
|
124
|
-
>['
|
|
124
|
+
>['ForgotPassword'];
|
|
125
125
|
|
|
126
|
-
type
|
|
126
|
+
type SetupTotpComponent<P = {}> = OverrideComponents<
|
|
127
127
|
TextFieldOptionsType,
|
|
128
|
-
{ style?:
|
|
129
|
-
>['
|
|
128
|
+
{ style?: SetupTotpStyle } & P
|
|
129
|
+
>['SetupTotp'];
|
|
130
130
|
|
|
131
131
|
type SignInComponent<P = {}> = OverrideComponents<
|
|
132
132
|
TextFieldOptionsType,
|
|
@@ -152,8 +152,8 @@ export interface Components {
|
|
|
152
152
|
ConfirmResetPassword?: ConfirmResetPasswordComponent;
|
|
153
153
|
ConfirmVerifyUser?: ConfirmVerifyUserComponent;
|
|
154
154
|
ForceNewPassword?: ForceNewPasswordComponent;
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
ForgotPassword?: ForgotPasswordComponent;
|
|
156
|
+
SetupTotp?: SetupTotpComponent;
|
|
157
157
|
SignIn?: SignInComponent;
|
|
158
158
|
SignUp?: SignUpComponent;
|
|
159
159
|
VerifyUser?: VerifyUserComponent;
|
|
@@ -3,7 +3,6 @@ import React from 'react';
|
|
|
3
3
|
import { Button, Icon, Label } from '../../../primitives';
|
|
4
4
|
import { usePressableContainerStyles } from '../../../hooks';
|
|
5
5
|
|
|
6
|
-
import { styles } from './styles';
|
|
7
6
|
import { FederatedProviderButtonProps } from './types';
|
|
8
7
|
|
|
9
8
|
export default function FederatedProviderButton({
|
|
@@ -14,14 +13,13 @@ export default function FederatedProviderButton({
|
|
|
14
13
|
...rest
|
|
15
14
|
}: FederatedProviderButtonProps): JSX.Element {
|
|
16
15
|
const pressableStyle = usePressableContainerStyles({
|
|
17
|
-
containerStyle: styles.container,
|
|
18
16
|
overrideStyle: style,
|
|
19
17
|
});
|
|
20
18
|
|
|
21
19
|
return (
|
|
22
20
|
<Button {...rest} style={pressableStyle}>
|
|
23
|
-
<Icon source={source}
|
|
24
|
-
<Label style={
|
|
21
|
+
<Icon source={source} size={20} />
|
|
22
|
+
<Label style={textStyle}>{children}</Label>
|
|
25
23
|
</Button>
|
|
26
24
|
);
|
|
27
25
|
}
|
|
@@ -7,7 +7,9 @@ import {
|
|
|
7
7
|
|
|
8
8
|
import { ButtonProps } from '../../../primitives';
|
|
9
9
|
|
|
10
|
-
export interface FederatedProviderButtonProps
|
|
10
|
+
export interface FederatedProviderButtonProps
|
|
11
|
+
extends Omit<ButtonProps, 'children'> {
|
|
12
|
+
children?: React.ReactNode;
|
|
11
13
|
source: ImageSourcePropType;
|
|
12
14
|
}
|
|
13
15
|
|
|
@@ -1,25 +1,48 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
|
-
import {
|
|
3
|
+
import { signInWithRedirect } from 'aws-amplify/auth';
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import {
|
|
6
|
+
SocialProvider,
|
|
7
|
+
authenticatorTextUtil,
|
|
8
|
+
capitalize,
|
|
9
|
+
} from '@aws-amplify/ui';
|
|
8
10
|
|
|
9
|
-
import {
|
|
11
|
+
import { Divider } from '../../../primitives';
|
|
12
|
+
import { useTheme } from '../../../theme';
|
|
13
|
+
import { FederatedProviderButton } from '../FederatedProviderButton';
|
|
10
14
|
import { FederatedProviderButtonsProps } from './types';
|
|
15
|
+
import { icons } from '../../../assets';
|
|
16
|
+
import { getThemedStyles } from './styles';
|
|
17
|
+
|
|
18
|
+
const { getSignInWithFederationText, getOrText } = authenticatorTextUtil;
|
|
19
|
+
|
|
20
|
+
// use `signInWithRedirect` directly instead of `toFederatedSignIn`
|
|
21
|
+
// exposed on `useAuthenticator` for RN. `@aws-amplify/rtn-web-browser`
|
|
22
|
+
// does not emit an event on federated sign in flow cancellation,
|
|
23
|
+
// preventing the `Authenticator` from updating state and leaving the
|
|
24
|
+
// UI in a "pending" state
|
|
25
|
+
const handleSignInWithRedirect = (
|
|
26
|
+
provider: 'amazon' | 'apple' | 'facebook' | 'google'
|
|
27
|
+
) => signInWithRedirect({ provider: capitalize(provider) });
|
|
11
28
|
|
|
12
29
|
export default function FederatedProviderButtons({
|
|
30
|
+
buttonStyle,
|
|
31
|
+
dividerLabelStyle,
|
|
32
|
+
route,
|
|
13
33
|
socialProviders,
|
|
14
|
-
|
|
34
|
+
style,
|
|
15
35
|
}: FederatedProviderButtonsProps): JSX.Element | null {
|
|
36
|
+
const theme = useTheme();
|
|
37
|
+
const themedStyle = getThemedStyles(theme);
|
|
38
|
+
|
|
16
39
|
const providerButtons = useMemo(
|
|
17
40
|
() =>
|
|
18
|
-
socialProviders?.map((provider) => {
|
|
41
|
+
socialProviders?.map((provider: SocialProvider) => {
|
|
19
42
|
const providerIconSource = icons[`${provider}Logo`];
|
|
20
43
|
|
|
21
44
|
const handlePress = () => {
|
|
22
|
-
|
|
45
|
+
handleSignInWithRedirect(provider);
|
|
23
46
|
};
|
|
24
47
|
|
|
25
48
|
return (
|
|
@@ -27,19 +50,24 @@ export default function FederatedProviderButtons({
|
|
|
27
50
|
key={provider}
|
|
28
51
|
onPress={handlePress}
|
|
29
52
|
source={providerIconSource}
|
|
30
|
-
style={
|
|
53
|
+
style={[themedStyle.button, buttonStyle]}
|
|
31
54
|
>
|
|
32
|
-
{
|
|
55
|
+
{getSignInWithFederationText(route, provider)}
|
|
33
56
|
</FederatedProviderButton>
|
|
34
57
|
);
|
|
35
58
|
}),
|
|
36
|
-
[socialProviders,
|
|
59
|
+
[route, socialProviders, themedStyle, buttonStyle]
|
|
37
60
|
);
|
|
38
61
|
|
|
39
62
|
return providerButtons?.length ? (
|
|
40
|
-
<View
|
|
63
|
+
<View
|
|
64
|
+
style={[themedStyle.container, style]}
|
|
65
|
+
testID="amplify__federated-provider-buttons"
|
|
66
|
+
>
|
|
41
67
|
{providerButtons}
|
|
42
|
-
<Divider labelStyle={
|
|
68
|
+
<Divider labelStyle={[themedStyle.dividerLabel, dividerLabelStyle]}>
|
|
69
|
+
{getOrText()}
|
|
70
|
+
</Divider>
|
|
43
71
|
</View>
|
|
44
72
|
) : null;
|
|
45
73
|
}
|
|
@@ -1,7 +1,22 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import { StrictTheme } from '../../../theme';
|
|
1
4
|
import { FederatedProviderButtonStyle } from './types';
|
|
2
5
|
|
|
3
|
-
export const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
export const getThemedStyles = (
|
|
7
|
+
theme: StrictTheme
|
|
8
|
+
): FederatedProviderButtonStyle => {
|
|
9
|
+
const { space } = theme.tokens;
|
|
10
|
+
|
|
11
|
+
return StyleSheet.create({
|
|
12
|
+
button: {
|
|
13
|
+
marginVertical: space.xs,
|
|
14
|
+
},
|
|
15
|
+
dividerLabel: {
|
|
16
|
+
textAlign: 'center',
|
|
17
|
+
},
|
|
18
|
+
container: {
|
|
19
|
+
marginHorizontal: space.small,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
7
22
|
};
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { TextStyle, ViewStyle } from 'react-native';
|
|
1
|
+
import { StyleProp, TextStyle, ViewProps, ViewStyle } from 'react-native';
|
|
2
2
|
|
|
3
3
|
import { AuthenticatorMachineContext } from '@aws-amplify/ui-react-core';
|
|
4
4
|
|
|
5
|
-
// TODO extend from ViewProps, add button style related style props
|
|
6
5
|
export interface FederatedProviderButtonsProps
|
|
7
6
|
extends Pick<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
AuthenticatorMachineContext,
|
|
8
|
+
'route' | 'socialProviders' | 'toFederatedSignIn'
|
|
9
|
+
>,
|
|
10
|
+
ViewProps {
|
|
11
|
+
buttonStyle?: StyleProp<ViewStyle>;
|
|
12
|
+
dividerLabelStyle?: StyleProp<TextStyle>;
|
|
13
|
+
}
|
|
11
14
|
|
|
12
15
|
export interface FederatedProviderButtonStyle {
|
|
13
16
|
button: ViewStyle;
|
|
14
17
|
container: ViewStyle;
|
|
15
|
-
|
|
18
|
+
dividerLabel: TextStyle;
|
|
16
19
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useMemo, useState } from 'react';
|
|
2
|
-
import { Logger } from 'aws-amplify';
|
|
2
|
+
import { ConsoleLogger as Logger } from 'aws-amplify/utils';
|
|
3
3
|
import { ValidationError } from '@aws-amplify/ui';
|
|
4
4
|
|
|
5
5
|
import { OnChangeText, TextFieldOnBlur, TypedField } from '../types';
|
|
@@ -7,11 +7,8 @@ import { Components } from './Defaults';
|
|
|
7
7
|
|
|
8
8
|
type SupportedAuthenticatorMachineOptions = Omit<
|
|
9
9
|
AuthenticatorMachineOptions,
|
|
10
|
-
// `socialProviders` not supported as a prop,
|
|
11
|
-
// feature is not enabled in React Native `Authenticator`
|
|
12
|
-
| 'socialProviders'
|
|
13
10
|
// `formFields` prop in RWA is to be deprecated
|
|
14
|
-
|
|
11
|
+
'formFields'
|
|
15
12
|
>;
|
|
16
13
|
|
|
17
14
|
export interface AuthenticatorProps
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Linking } from 'react-native';
|
|
2
|
-
import { ConsoleLogger as Logger } from '
|
|
2
|
+
import { ConsoleLogger as Logger } from 'aws-amplify/utils';
|
|
3
3
|
import { HandleMessageLinkAction } from '@aws-amplify/ui-react-core-notifications';
|
|
4
4
|
|
|
5
|
-
const logger = new Logger('
|
|
5
|
+
const logger = new Logger('InAppMessaging');
|
|
6
6
|
|
|
7
7
|
const handleMessageLinkAction: HandleMessageLinkAction = async (
|
|
8
8
|
url: string
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { Image } from 'react-native';
|
|
3
|
+
import { ConsoleLogger as Logger } from 'aws-amplify/utils';
|
|
3
4
|
|
|
4
|
-
import { ConsoleLogger as Logger } from '@aws-amplify/core';
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
InAppMessageImage,
|
|
7
|
+
InAppMessageLayout,
|
|
8
8
|
} from '@aws-amplify/ui-react-core-notifications';
|
|
9
9
|
|
|
10
10
|
import { ImageDimensions, ImagePrefetchStatus, UseMessageImage } from './types';
|
|
11
11
|
import { getLayoutImageDimensions, prefetchNetworkImage } from './utils';
|
|
12
12
|
|
|
13
|
-
const logger = new Logger('
|
|
13
|
+
const logger = new Logger('InAppMessaging');
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Handles prefetching and dimension setting for message images
|
|
@@ -20,8 +20,8 @@ const logger = new Logger('Notifications.InAppMessaging');
|
|
|
20
20
|
* @returns message image dimensions and rendering related booleans
|
|
21
21
|
*/
|
|
22
22
|
export default function useMessageImage(
|
|
23
|
-
image:
|
|
24
|
-
layout:
|
|
23
|
+
image: InAppMessageImage | undefined,
|
|
24
|
+
layout: InAppMessageLayout
|
|
25
25
|
): UseMessageImage {
|
|
26
26
|
const { src } = image ?? {};
|
|
27
27
|
const shouldPrefetch = !!src;
|