@aws-amplify/ui-react-native 2.0.8 → 2.1.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/common/FederatedProviderButtons/FederatedProviderButtons.d.ts +1 -1
- package/dist/Authenticator/common/FederatedProviderButtons/FederatedProviderButtons.js +3 -10
- package/dist/Authenticator/index.d.ts +1 -1
- package/dist/Authenticator/index.js +1 -2
- package/dist/Authenticator/useAuthenticator.d.ts +4 -0
- package/dist/Authenticator/useAuthenticator.js +18 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/lib/Authenticator/common/FederatedProviderButtons/FederatedProviderButtons.js +3 -10
- package/lib/Authenticator/index.js +3 -4
- package/lib/Authenticator/useAuthenticator.js +22 -0
- package/lib/version.js +1 -1
- package/package.json +5 -5
- package/src/Authenticator/common/DefaultContent/DefaultContent.tsx +1 -1
- package/src/Authenticator/common/FederatedProviderButtons/FederatedProviderButtons.tsx +3 -12
- package/src/Authenticator/index.ts +1 -3
- package/src/Authenticator/useAuthenticator.ts +34 -0
- package/src/version.ts +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { FederatedProviderButtonsProps } from './types';
|
|
3
|
-
export default function FederatedProviderButtons({ buttonStyle, dividerLabelStyle, route, socialProviders, style, }: FederatedProviderButtonsProps): JSX.Element | null;
|
|
3
|
+
export default function FederatedProviderButtons({ buttonStyle, dividerLabelStyle, route, socialProviders, style, toFederatedSignIn, }: FederatedProviderButtonsProps): JSX.Element | null;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
|
-
import { signInWithRedirect } from 'aws-amplify/auth';
|
|
4
3
|
import { authenticatorTextUtil, capitalize, } from '@aws-amplify/ui';
|
|
5
4
|
import { Divider } from '../../../primitives';
|
|
6
5
|
import { useTheme } from '../../../theme';
|
|
@@ -8,24 +7,18 @@ import { FederatedProviderButton } from '../FederatedProviderButton';
|
|
|
8
7
|
import { icons } from '../../../assets';
|
|
9
8
|
import { getThemedStyles } from './styles';
|
|
10
9
|
const { getSignInWithFederationText, getOrText } = authenticatorTextUtil;
|
|
11
|
-
|
|
12
|
-
// exposed on `useAuthenticator` for RN. `@aws-amplify/rtn-web-browser`
|
|
13
|
-
// does not emit an event on federated sign in flow cancellation,
|
|
14
|
-
// preventing the `Authenticator` from updating state and leaving the
|
|
15
|
-
// UI in a "pending" state
|
|
16
|
-
const handleSignInWithRedirect = (provider) => signInWithRedirect({ provider: capitalize(provider) });
|
|
17
|
-
export default function FederatedProviderButtons({ buttonStyle, dividerLabelStyle, route, socialProviders, style, }) {
|
|
10
|
+
export default function FederatedProviderButtons({ buttonStyle, dividerLabelStyle, route, socialProviders, style, toFederatedSignIn, }) {
|
|
18
11
|
const theme = useTheme();
|
|
19
12
|
const themedStyle = getThemedStyles(theme);
|
|
20
13
|
const providerButtons = useMemo(() => socialProviders?.map((provider) => {
|
|
21
14
|
const providerIconSource = icons[`${provider}Logo`];
|
|
22
15
|
const handlePress = () => {
|
|
23
|
-
|
|
16
|
+
toFederatedSignIn({ provider: capitalize(provider) });
|
|
24
17
|
};
|
|
25
18
|
return (<FederatedProviderButton key={provider} onPress={handlePress} source={providerIconSource} style={[themedStyle.button, buttonStyle]}>
|
|
26
19
|
{getSignInWithFederationText(route, provider)}
|
|
27
20
|
</FederatedProviderButton>);
|
|
28
|
-
}), [route, socialProviders, themedStyle, buttonStyle]);
|
|
21
|
+
}), [route, socialProviders, themedStyle, buttonStyle, toFederatedSignIn]);
|
|
29
22
|
return providerButtons?.length ? (<View style={[themedStyle.container, style]} testID="amplify__federated-provider-buttons">
|
|
30
23
|
{providerButtons}
|
|
31
24
|
<Divider labelStyle={[themedStyle.dividerLabel, dividerLabelStyle]}>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { default as Authenticator } from './Authenticator';
|
|
2
2
|
export { AuthenticatorProps, WithAuthenticatorOptions } from './types';
|
|
3
|
+
export { useAuthenticator, UseAuthenticator } from './useAuthenticator';
|
|
3
4
|
export { default as withAuthenticator } from './withAuthenticator';
|
|
4
|
-
export { useAuthenticator, UseAuthenticator } from '@aws-amplify/ui-react-core';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { default as Authenticator } from './Authenticator';
|
|
2
|
+
export { useAuthenticator } from './useAuthenticator';
|
|
2
3
|
export { default as withAuthenticator } from './withAuthenticator';
|
|
3
|
-
// re-export shared `Authenticator` exports
|
|
4
|
-
export { useAuthenticator } from '@aws-amplify/ui-react-core';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { UseAuthenticator } from '@aws-amplify/ui-react-core';
|
|
2
|
+
import { useAuthenticator as _useAuthenticator, UseAuthenticator } from '@aws-amplify/ui-react-core';
|
|
3
|
+
type UseAuthenticatorSelector = Parameters<typeof _useAuthenticator>[0];
|
|
4
|
+
export declare function useAuthenticator(selector?: UseAuthenticatorSelector): UseAuthenticator;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { signOut as _signOut } from 'aws-amplify/auth';
|
|
2
|
+
import { useAuthenticator as _useAuthenticator, } from '@aws-amplify/ui-react-core';
|
|
3
|
+
// wrap and re-export `useAuthenticator` to replace state machine `signOut` with
|
|
4
|
+
// `aws-amplify/auth` version due to iOS specifc requirements for federated sign
|
|
5
|
+
// out handling with JS. On iOS sign out, JS prmnpts the end user with a native
|
|
6
|
+
// Alert requesting confirmation of sign out, if the end user cancels they will
|
|
7
|
+
// have already been signed out of the state machine, but will still be
|
|
8
|
+
// authenticated on the JS singleton
|
|
9
|
+
// input utility function to prevent breaking changes in consumers.
|
|
10
|
+
// State machine sign out handling does not pass input to underlying `signOut`
|
|
11
|
+
// call; replicate that behavior here
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
13
|
+
const signOut = (data) => {
|
|
14
|
+
_signOut();
|
|
15
|
+
};
|
|
16
|
+
export function useAuthenticator(selector) {
|
|
17
|
+
return { ..._useAuthenticator(selector), signOut };
|
|
18
|
+
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "2.
|
|
1
|
+
export declare const VERSION = "2.1.1";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '2.
|
|
1
|
+
export const VERSION = '2.1.1';
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
5
|
const react_native_1 = require("react-native");
|
|
6
|
-
const auth_1 = require("aws-amplify/auth");
|
|
7
6
|
const ui_1 = require("@aws-amplify/ui");
|
|
8
7
|
const primitives_1 = require("../../../primitives");
|
|
9
8
|
const theme_1 = require("../../../theme");
|
|
@@ -11,24 +10,18 @@ const FederatedProviderButton_1 = require("../FederatedProviderButton");
|
|
|
11
10
|
const assets_1 = require("../../../assets");
|
|
12
11
|
const styles_1 = require("./styles");
|
|
13
12
|
const { getSignInWithFederationText, getOrText } = ui_1.authenticatorTextUtil;
|
|
14
|
-
|
|
15
|
-
// exposed on `useAuthenticator` for RN. `@aws-amplify/rtn-web-browser`
|
|
16
|
-
// does not emit an event on federated sign in flow cancellation,
|
|
17
|
-
// preventing the `Authenticator` from updating state and leaving the
|
|
18
|
-
// UI in a "pending" state
|
|
19
|
-
const handleSignInWithRedirect = (provider) => (0, auth_1.signInWithRedirect)({ provider: (0, ui_1.capitalize)(provider) });
|
|
20
|
-
function FederatedProviderButtons({ buttonStyle, dividerLabelStyle, route, socialProviders, style, }) {
|
|
13
|
+
function FederatedProviderButtons({ buttonStyle, dividerLabelStyle, route, socialProviders, style, toFederatedSignIn, }) {
|
|
21
14
|
const theme = (0, theme_1.useTheme)();
|
|
22
15
|
const themedStyle = (0, styles_1.getThemedStyles)(theme);
|
|
23
16
|
const providerButtons = (0, react_1.useMemo)(() => socialProviders?.map((provider) => {
|
|
24
17
|
const providerIconSource = assets_1.icons[`${provider}Logo`];
|
|
25
18
|
const handlePress = () => {
|
|
26
|
-
|
|
19
|
+
toFederatedSignIn({ provider: (0, ui_1.capitalize)(provider) });
|
|
27
20
|
};
|
|
28
21
|
return (<FederatedProviderButton_1.FederatedProviderButton key={provider} onPress={handlePress} source={providerIconSource} style={[themedStyle.button, buttonStyle]}>
|
|
29
22
|
{getSignInWithFederationText(route, provider)}
|
|
30
23
|
</FederatedProviderButton_1.FederatedProviderButton>);
|
|
31
|
-
}), [route, socialProviders, themedStyle, buttonStyle]);
|
|
24
|
+
}), [route, socialProviders, themedStyle, buttonStyle, toFederatedSignIn]);
|
|
32
25
|
return providerButtons?.length ? (<react_native_1.View style={[themedStyle.container, style]} testID="amplify__federated-provider-buttons">
|
|
33
26
|
{providerButtons}
|
|
34
27
|
<primitives_1.Divider labelStyle={[themedStyle.dividerLabel, dividerLabelStyle]}>
|
|
@@ -3,11 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.withAuthenticator = exports.useAuthenticator = exports.Authenticator = void 0;
|
|
7
7
|
var Authenticator_1 = require("./Authenticator");
|
|
8
8
|
Object.defineProperty(exports, "Authenticator", { enumerable: true, get: function () { return __importDefault(Authenticator_1).default; } });
|
|
9
|
+
var useAuthenticator_1 = require("./useAuthenticator");
|
|
10
|
+
Object.defineProperty(exports, "useAuthenticator", { enumerable: true, get: function () { return useAuthenticator_1.useAuthenticator; } });
|
|
9
11
|
var withAuthenticator_1 = require("./withAuthenticator");
|
|
10
12
|
Object.defineProperty(exports, "withAuthenticator", { enumerable: true, get: function () { return __importDefault(withAuthenticator_1).default; } });
|
|
11
|
-
// re-export shared `Authenticator` exports
|
|
12
|
-
var ui_react_core_1 = require("@aws-amplify/ui-react-core");
|
|
13
|
-
Object.defineProperty(exports, "useAuthenticator", { enumerable: true, get: function () { return ui_react_core_1.useAuthenticator; } });
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useAuthenticator = void 0;
|
|
4
|
+
const auth_1 = require("aws-amplify/auth");
|
|
5
|
+
const ui_react_core_1 = require("@aws-amplify/ui-react-core");
|
|
6
|
+
// wrap and re-export `useAuthenticator` to replace state machine `signOut` with
|
|
7
|
+
// `aws-amplify/auth` version due to iOS specifc requirements for federated sign
|
|
8
|
+
// out handling with JS. On iOS sign out, JS prmnpts the end user with a native
|
|
9
|
+
// Alert requesting confirmation of sign out, if the end user cancels they will
|
|
10
|
+
// have already been signed out of the state machine, but will still be
|
|
11
|
+
// authenticated on the JS singleton
|
|
12
|
+
// input utility function to prevent breaking changes in consumers.
|
|
13
|
+
// State machine sign out handling does not pass input to underlying `signOut`
|
|
14
|
+
// call; replicate that behavior here
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16
|
+
const signOut = (data) => {
|
|
17
|
+
(0, auth_1.signOut)();
|
|
18
|
+
};
|
|
19
|
+
function useAuthenticator(selector) {
|
|
20
|
+
return { ...(0, ui_react_core_1.useAuthenticator)(selector), signOut };
|
|
21
|
+
}
|
|
22
|
+
exports.useAuthenticator = useAuthenticator;
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/ui-react-native",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"react-native": "src/index.ts",
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"react-native-safe-area-context": "^4.7.3"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@aws-amplify/ui": "6.0.
|
|
33
|
-
"@aws-amplify/ui-react-core": "3.0.
|
|
34
|
-
"@aws-amplify/ui-react-core-notifications": "2.0.
|
|
32
|
+
"@aws-amplify/ui": "6.0.9",
|
|
33
|
+
"@aws-amplify/ui-react-core": "3.0.9",
|
|
34
|
+
"@aws-amplify/ui-react-core-notifications": "2.0.9"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"aws-amplify": "^6.0.2",
|
|
38
|
-
"react-native": "^0.70 || ^0.71 || ^0.72",
|
|
38
|
+
"react-native": "^0.70 || ^0.71 || ^0.72 || ^0.73",
|
|
39
39
|
"react-native-safe-area-context": "^4.2.5"
|
|
40
40
|
},
|
|
41
41
|
"files": [
|
|
@@ -14,7 +14,7 @@ function useThemedStyles<Style>(getStyle: (theme: StrictTheme) => Style) {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export default function DefaultContent<
|
|
17
|
-
FieldsType extends TextFieldOptionsType | RadioFieldOptions
|
|
17
|
+
FieldsType extends TextFieldOptionsType | RadioFieldOptions,
|
|
18
18
|
>({
|
|
19
19
|
body,
|
|
20
20
|
buttons: { primary, links, secondary },
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
|
-
import { signInWithRedirect } from 'aws-amplify/auth';
|
|
4
3
|
|
|
5
4
|
import {
|
|
6
5
|
SocialProvider,
|
|
@@ -17,21 +16,13 @@ import { getThemedStyles } from './styles';
|
|
|
17
16
|
|
|
18
17
|
const { getSignInWithFederationText, getOrText } = authenticatorTextUtil;
|
|
19
18
|
|
|
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) });
|
|
28
|
-
|
|
29
19
|
export default function FederatedProviderButtons({
|
|
30
20
|
buttonStyle,
|
|
31
21
|
dividerLabelStyle,
|
|
32
22
|
route,
|
|
33
23
|
socialProviders,
|
|
34
24
|
style,
|
|
25
|
+
toFederatedSignIn,
|
|
35
26
|
}: FederatedProviderButtonsProps): JSX.Element | null {
|
|
36
27
|
const theme = useTheme();
|
|
37
28
|
const themedStyle = getThemedStyles(theme);
|
|
@@ -42,7 +33,7 @@ export default function FederatedProviderButtons({
|
|
|
42
33
|
const providerIconSource = icons[`${provider}Logo`];
|
|
43
34
|
|
|
44
35
|
const handlePress = () => {
|
|
45
|
-
|
|
36
|
+
toFederatedSignIn({ provider: capitalize(provider) });
|
|
46
37
|
};
|
|
47
38
|
|
|
48
39
|
return (
|
|
@@ -56,7 +47,7 @@ export default function FederatedProviderButtons({
|
|
|
56
47
|
</FederatedProviderButton>
|
|
57
48
|
);
|
|
58
49
|
}),
|
|
59
|
-
[route, socialProviders, themedStyle, buttonStyle]
|
|
50
|
+
[route, socialProviders, themedStyle, buttonStyle, toFederatedSignIn]
|
|
60
51
|
);
|
|
61
52
|
|
|
62
53
|
return providerButtons?.length ? (
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export { default as Authenticator } from './Authenticator';
|
|
2
2
|
export { AuthenticatorProps, WithAuthenticatorOptions } from './types';
|
|
3
|
+
export { useAuthenticator, UseAuthenticator } from './useAuthenticator';
|
|
3
4
|
export { default as withAuthenticator } from './withAuthenticator';
|
|
4
|
-
|
|
5
|
-
// re-export shared `Authenticator` exports
|
|
6
|
-
export { useAuthenticator, UseAuthenticator } from '@aws-amplify/ui-react-core';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// re-export `UseAuthenticator` export
|
|
2
|
+
export { UseAuthenticator } from '@aws-amplify/ui-react-core';
|
|
3
|
+
|
|
4
|
+
import { signOut as _signOut } from 'aws-amplify/auth';
|
|
5
|
+
import { AuthEventData } from '@aws-amplify/ui';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
useAuthenticator as _useAuthenticator,
|
|
9
|
+
UseAuthenticator,
|
|
10
|
+
} from '@aws-amplify/ui-react-core';
|
|
11
|
+
|
|
12
|
+
// wrap and re-export `useAuthenticator` to replace state machine `signOut` with
|
|
13
|
+
// `aws-amplify/auth` version due to iOS specifc requirements for federated sign
|
|
14
|
+
// out handling with JS. On iOS sign out, JS prmnpts the end user with a native
|
|
15
|
+
// Alert requesting confirmation of sign out, if the end user cancels they will
|
|
16
|
+
// have already been signed out of the state machine, but will still be
|
|
17
|
+
// authenticated on the JS singleton
|
|
18
|
+
|
|
19
|
+
// input utility function to prevent breaking changes in consumers.
|
|
20
|
+
// State machine sign out handling does not pass input to underlying `signOut`
|
|
21
|
+
// call; replicate that behavior here
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
23
|
+
const signOut = (data?: AuthEventData) => {
|
|
24
|
+
_signOut();
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// selector utility type to prevent breaking type changes in consumers
|
|
28
|
+
type UseAuthenticatorSelector = Parameters<typeof _useAuthenticator>[0];
|
|
29
|
+
|
|
30
|
+
export function useAuthenticator(
|
|
31
|
+
selector?: UseAuthenticatorSelector
|
|
32
|
+
): UseAuthenticator {
|
|
33
|
+
return { ..._useAuthenticator(selector), signOut };
|
|
34
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '2.
|
|
1
|
+
export const VERSION = '2.1.1';
|