@aws-amplify/ui-react-core 2.1.23 → 2.1.25
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/esm/Authenticator/context/AuthenticatorContext.mjs +2 -2
- package/dist/esm/Authenticator/context/AuthenticatorProvider.mjs +4 -4
- package/dist/esm/Authenticator/hooks/useAuthenticator/useAuthenticator.mjs +2 -2
- package/dist/esm/Authenticator/hooks/useAuthenticatorInitMachine/useAuthenticatorInitMachine.mjs +3 -3
- package/dist/esm/Authenticator/hooks/useAuthenticatorRoute/constants.mjs +3 -0
- package/dist/esm/hooks/useDeprecationWarning.mjs +19 -0
- package/dist/esm/index.mjs +2 -1
- package/dist/index.js +39 -0
- package/dist/types/Authenticator/hooks/types.d.ts +7 -6
- package/dist/types/hooks/index.d.ts +2 -1
- package/dist/types/hooks/useDeprecationWarning.d.ts +13 -0
- package/dist/types/index.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React__default from 'react';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* AuthenticatorContext serves static reference to the auth machine service.
|
|
5
5
|
*
|
|
6
6
|
* https://xstate.js.org/docs/recipes/react.html#context-provider
|
|
7
7
|
*/
|
|
8
|
-
const AuthenticatorContext =
|
|
8
|
+
const AuthenticatorContext = React__default.createContext(null);
|
|
9
9
|
|
|
10
10
|
export { AuthenticatorContext };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __awaiter } from '../../node_modules/tslib/tslib.es6.mjs';
|
|
2
|
-
import
|
|
2
|
+
import React__default, { useContext, useMemo, useEffect } from 'react';
|
|
3
3
|
import { useInterpret } from '@xstate/react';
|
|
4
4
|
import { Auth } from 'aws-amplify';
|
|
5
5
|
import { createAuthenticatorMachine, listenToAuthHub, defaultAuthHubHandler } from '@aws-amplify/ui';
|
|
@@ -13,9 +13,9 @@ function AuthenticatorProvider({ children, }) {
|
|
|
13
13
|
// state machine as the machine only updates on `Authenticator` initiated events, which
|
|
14
14
|
// leads to scenarios where the state machine `authStatus` gets "stuck". For exmample,
|
|
15
15
|
// if a user was to sign in using `Auth.signIn` directly rather than using `Authenticator`
|
|
16
|
-
const [authStatus, setAuthStatus] =
|
|
16
|
+
const [authStatus, setAuthStatus] = React__default.useState('configuring');
|
|
17
17
|
// only run on first render
|
|
18
|
-
|
|
18
|
+
React__default.useEffect(() => {
|
|
19
19
|
Auth.currentAuthenticatedUser()
|
|
20
20
|
.then(() => {
|
|
21
21
|
setAuthStatus('authenticated');
|
|
@@ -45,7 +45,7 @@ function AuthenticatorProvider({ children, }) {
|
|
|
45
45
|
const unsubscribe = listenToAuthHub(activeService, createHubHandler({ onSignIn, onSignOut }));
|
|
46
46
|
return unsubscribe;
|
|
47
47
|
}, [activeService]);
|
|
48
|
-
return (
|
|
48
|
+
return (React__default.createElement(AuthenticatorContext.Provider, { value: value }, children));
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export { AuthenticatorProvider as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __rest } from '../../../node_modules/tslib/tslib.es6.mjs';
|
|
2
|
-
import
|
|
2
|
+
import React__default, { useCallback } from 'react';
|
|
3
3
|
import { useSelector } from '@xstate/react';
|
|
4
4
|
import { getServiceFacade } from '@aws-amplify/ui';
|
|
5
5
|
import 'aws-amplify';
|
|
@@ -11,7 +11,7 @@ import { getQRFields, getMachineFields, getTotpSecretCodeCallback, getComparator
|
|
|
11
11
|
* [📖 Docs](https://ui.docs.amplify.aws/react/connected-components/authenticator/headless#useauthenticator-hook)
|
|
12
12
|
*/
|
|
13
13
|
function useAuthenticator(selector) {
|
|
14
|
-
const context =
|
|
14
|
+
const context = React__default.useContext(AuthenticatorContext);
|
|
15
15
|
if (!context) {
|
|
16
16
|
throw new Error(USE_AUTHENTICATOR_ERROR);
|
|
17
17
|
}
|
package/dist/esm/Authenticator/hooks/useAuthenticatorInitMachine/useAuthenticatorInitMachine.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React__default from 'react';
|
|
2
2
|
import useAuthenticator from '../useAuthenticator/useAuthenticator.mjs';
|
|
3
3
|
|
|
4
4
|
// only select `route` from machine context
|
|
5
5
|
const routeSelector = ({ route }) => [route];
|
|
6
6
|
function useAuthenticatorInitMachine(data) {
|
|
7
7
|
const { route, initializeMachine } = useAuthenticator(routeSelector);
|
|
8
|
-
const hasInitialized =
|
|
9
|
-
|
|
8
|
+
const hasInitialized = React__default.useRef(false);
|
|
9
|
+
React__default.useEffect(() => {
|
|
10
10
|
if (!hasInitialized.current && route === 'setup') {
|
|
11
11
|
initializeMachine(data);
|
|
12
12
|
hasInitialized.current = true;
|
|
@@ -12,6 +12,7 @@ const COMMON_ROUTE_MACHINE_KEYS = [
|
|
|
12
12
|
];
|
|
13
13
|
const CONFIRM_RESET_PASSWORD_MACHINE_KEYS = [
|
|
14
14
|
...COMMON_ROUTE_MACHINE_KEYS,
|
|
15
|
+
'hasValidationErrors',
|
|
15
16
|
'resendCode',
|
|
16
17
|
'validationErrors',
|
|
17
18
|
];
|
|
@@ -31,6 +32,7 @@ const CONFIRM_VERIFY_USER_MACHINE_KEYS = [
|
|
|
31
32
|
];
|
|
32
33
|
const FORCE_NEW_PASSWORD_MACHINE_KEYS = [
|
|
33
34
|
...COMMON_ROUTE_MACHINE_KEYS,
|
|
35
|
+
'hasValidationErrors',
|
|
34
36
|
'toSignIn',
|
|
35
37
|
'validationErrors',
|
|
36
38
|
];
|
|
@@ -46,6 +48,7 @@ const SIGN_IN_MACHINE_KEYS = [
|
|
|
46
48
|
];
|
|
47
49
|
const SIGN_UP_MACHINE_KEYS = [
|
|
48
50
|
...COMMON_ROUTE_MACHINE_KEYS,
|
|
51
|
+
'hasValidationErrors',
|
|
49
52
|
'toSignIn',
|
|
50
53
|
'validationErrors',
|
|
51
54
|
];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Logs a deprecation warning message.
|
|
5
|
+
*
|
|
6
|
+
* @important Please use the React/React Native specific platform implementations.
|
|
7
|
+
* This version of the hook is a base implementation that the others extend from due
|
|
8
|
+
* to env differences between running in RN or the browser
|
|
9
|
+
*/
|
|
10
|
+
const useDeprecationWarning = ({ shouldWarn, message, }) => {
|
|
11
|
+
React.useEffect(() => {
|
|
12
|
+
if (shouldWarn) {
|
|
13
|
+
// eslint-disable-next-line no-console
|
|
14
|
+
console.warn(message);
|
|
15
|
+
}
|
|
16
|
+
}, [shouldWarn, message]);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { useDeprecationWarning as default };
|
package/dist/esm/index.mjs
CHANGED
|
@@ -5,6 +5,7 @@ export { default as useAuthenticatorRoute } from './Authenticator/hooks/useAuthe
|
|
|
5
5
|
export { default as useAuthenticatorInitMachine } from './Authenticator/hooks/useAuthenticatorInitMachine/useAuthenticatorInitMachine.mjs';
|
|
6
6
|
export { isComponentRouteKey as isAuthenticatorComponentRouteKey, resolveAuthenticatorComponents } from './Authenticator/hooks/utils.mjs';
|
|
7
7
|
export { default as RenderNothing } from './components/RenderNothing/RenderNothing.mjs';
|
|
8
|
-
export { default as
|
|
8
|
+
export { default as useDeprecationWarning } from './hooks/useDeprecationWarning.mjs';
|
|
9
9
|
export { default as useHasValueUpdated } from './hooks/useHasValueUpdated.mjs';
|
|
10
|
+
export { default as usePreviousValue } from './hooks/usePreviousValue.mjs';
|
|
10
11
|
export { templateJoin } from './utils/index.mjs';
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,26 @@ var ui = require('@aws-amplify/ui');
|
|
|
9
9
|
|
|
10
10
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
11
|
|
|
12
|
+
function _interopNamespace(e) {
|
|
13
|
+
if (e && e.__esModule) return e;
|
|
14
|
+
var n = Object.create(null);
|
|
15
|
+
if (e) {
|
|
16
|
+
Object.keys(e).forEach(function (k) {
|
|
17
|
+
if (k !== 'default') {
|
|
18
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
19
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return e[k]; }
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
n["default"] = e;
|
|
27
|
+
return Object.freeze(n);
|
|
28
|
+
}
|
|
29
|
+
|
|
12
30
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
31
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
13
32
|
|
|
14
33
|
/******************************************************************************
|
|
15
34
|
Copyright (c) Microsoft Corporation.
|
|
@@ -257,6 +276,7 @@ const COMMON_ROUTE_MACHINE_KEYS = [
|
|
|
257
276
|
];
|
|
258
277
|
const CONFIRM_RESET_PASSWORD_MACHINE_KEYS = [
|
|
259
278
|
...COMMON_ROUTE_MACHINE_KEYS,
|
|
279
|
+
'hasValidationErrors',
|
|
260
280
|
'resendCode',
|
|
261
281
|
'validationErrors',
|
|
262
282
|
];
|
|
@@ -276,6 +296,7 @@ const CONFIRM_VERIFY_USER_MACHINE_KEYS = [
|
|
|
276
296
|
];
|
|
277
297
|
const FORCE_NEW_PASSWORD_MACHINE_KEYS = [
|
|
278
298
|
...COMMON_ROUTE_MACHINE_KEYS,
|
|
299
|
+
'hasValidationErrors',
|
|
279
300
|
'toSignIn',
|
|
280
301
|
'validationErrors',
|
|
281
302
|
];
|
|
@@ -291,6 +312,7 @@ const SIGN_IN_MACHINE_KEYS = [
|
|
|
291
312
|
];
|
|
292
313
|
const SIGN_UP_MACHINE_KEYS = [
|
|
293
314
|
...COMMON_ROUTE_MACHINE_KEYS,
|
|
315
|
+
'hasValidationErrors',
|
|
294
316
|
'toSignIn',
|
|
295
317
|
'validationErrors',
|
|
296
318
|
];
|
|
@@ -458,6 +480,22 @@ function useAuthenticatorInitMachine(data) {
|
|
|
458
480
|
}, [initializeMachine, route, data]);
|
|
459
481
|
}
|
|
460
482
|
|
|
483
|
+
/**
|
|
484
|
+
* Logs a deprecation warning message.
|
|
485
|
+
*
|
|
486
|
+
* @important Please use the React/React Native specific platform implementations.
|
|
487
|
+
* This version of the hook is a base implementation that the others extend from due
|
|
488
|
+
* to env differences between running in RN or the browser
|
|
489
|
+
*/
|
|
490
|
+
const useDeprecationWarning = ({ shouldWarn, message, }) => {
|
|
491
|
+
React__namespace.useEffect(() => {
|
|
492
|
+
if (shouldWarn) {
|
|
493
|
+
// eslint-disable-next-line no-console
|
|
494
|
+
console.warn(message);
|
|
495
|
+
}
|
|
496
|
+
}, [shouldWarn, message]);
|
|
497
|
+
};
|
|
498
|
+
|
|
461
499
|
function usePreviousValue(value) {
|
|
462
500
|
const previous = React.useRef();
|
|
463
501
|
// update ref post render
|
|
@@ -489,5 +527,6 @@ exports.templateJoin = templateJoin;
|
|
|
489
527
|
exports.useAuthenticator = useAuthenticator;
|
|
490
528
|
exports.useAuthenticatorInitMachine = useAuthenticatorInitMachine;
|
|
491
529
|
exports.useAuthenticatorRoute = useAuthenticatorRoute;
|
|
530
|
+
exports.useDeprecationWarning = useDeprecationWarning;
|
|
492
531
|
exports.useHasValueUpdated = useHasValueUpdated;
|
|
493
532
|
exports.usePreviousValue = usePreviousValue;
|
|
@@ -41,13 +41,16 @@ export type CommonRouteProps = {
|
|
|
41
41
|
handleChange: UseAuthenticator['updateForm'];
|
|
42
42
|
handleSubmit: UseAuthenticator['submitForm'];
|
|
43
43
|
};
|
|
44
|
+
export interface ValidationProps {
|
|
45
|
+
hasValidationErrors: UseAuthenticator['hasValidationErrors'];
|
|
46
|
+
validationErrors?: UseAuthenticator['validationErrors'];
|
|
47
|
+
}
|
|
44
48
|
/**
|
|
45
49
|
* Base Route component props
|
|
46
50
|
*/
|
|
47
51
|
export type ConfirmResetPasswordBaseProps<FieldType = {}> = {
|
|
48
52
|
resendCode: UseAuthenticator['resendCode'];
|
|
49
|
-
|
|
50
|
-
} & CommonRouteProps & ComponentSlots<FieldType>;
|
|
53
|
+
} & CommonRouteProps & ComponentSlots<FieldType> & ValidationProps;
|
|
51
54
|
export type ConfirmSignInBaseProps<FieldType = {}> = {
|
|
52
55
|
challengeName: AuthChallengeName;
|
|
53
56
|
toSignIn: UseAuthenticator['toSignIn'];
|
|
@@ -61,8 +64,7 @@ export type ConfirmVerifyUserProps<FieldType = {}> = {
|
|
|
61
64
|
} & CommonRouteProps & ComponentSlots<FieldType>;
|
|
62
65
|
export type ForceResetPasswordBaseProps<FieldType = {}> = {
|
|
63
66
|
toSignIn: UseAuthenticator['toSignIn'];
|
|
64
|
-
|
|
65
|
-
} & CommonRouteProps & ComponentSlots<FieldType>;
|
|
67
|
+
} & CommonRouteProps & ComponentSlots<FieldType> & ValidationProps;
|
|
66
68
|
export type ResetPasswordBaseProps<FieldType = {}> = {
|
|
67
69
|
toSignIn: UseAuthenticator['toSignIn'];
|
|
68
70
|
} & CommonRouteProps & ComponentSlots<FieldType>;
|
|
@@ -80,8 +82,7 @@ export type SignUpBaseProps<FieldType = {}> = {
|
|
|
80
82
|
hideSignIn?: boolean;
|
|
81
83
|
toFederatedSignIn: UseAuthenticator['toFederatedSignIn'];
|
|
82
84
|
toSignIn: UseAuthenticator['toSignIn'];
|
|
83
|
-
|
|
84
|
-
} & CommonRouteProps & ComponentSlots<FieldType>;
|
|
85
|
+
} & CommonRouteProps & ComponentSlots<FieldType> & ValidationProps;
|
|
85
86
|
export type VerifyUserProps<FieldType = {}> = {
|
|
86
87
|
skipVerification: UseAuthenticator['skipVerification'];
|
|
87
88
|
} & CommonRouteProps & ComponentSlots<FieldType>;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { default as
|
|
1
|
+
export { default as useDeprecationWarning, UseDeprecationWarning, } from './useDeprecationWarning';
|
|
2
2
|
export { default as useHasValueUpdated } from './useHasValueUpdated';
|
|
3
|
+
export { default as usePreviousValue } from './usePreviousValue';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type UseDeprecationWarning = (params: {
|
|
2
|
+
shouldWarn: boolean;
|
|
3
|
+
message: string;
|
|
4
|
+
}) => void;
|
|
5
|
+
/**
|
|
6
|
+
* Logs a deprecation warning message.
|
|
7
|
+
*
|
|
8
|
+
* @important Please use the React/React Native specific platform implementations.
|
|
9
|
+
* This version of the hook is a base implementation that the others extend from due
|
|
10
|
+
* to env differences between running in RN or the browser
|
|
11
|
+
*/
|
|
12
|
+
declare const useDeprecationWarning: UseDeprecationWarning;
|
|
13
|
+
export default useDeprecationWarning;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { AuthenticatorComponentDefaults, AuthenticatorComponentDefaultProps, AuthenticatorComponentOverrides, AuthenticatorFooterComponent, AuthenticatorFormFieldsComponent, AuthenticatorHeaderComponent, AuthenticatorLegacyField, AuthenticatorMachineContext, AuthenticatorProvider, AuthenticatorRouteComponentKey, AuthenticatorRouteComponentName, isAuthenticatorComponentRouteKey, resolveAuthenticatorComponents, useAuthenticator, useAuthenticatorRoute, UseAuthenticator, useAuthenticatorInitMachine, UseAuthenticatorRoute, } from './Authenticator';
|
|
2
2
|
export { RenderNothing } from './components';
|
|
3
|
-
export { useHasValueUpdated, usePreviousValue } from './hooks';
|
|
3
|
+
export { useDeprecationWarning, UseDeprecationWarning, useHasValueUpdated, usePreviousValue, } from './hooks';
|
|
4
4
|
export { templateJoin } from './utils';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/ui-react-core",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.25",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/esm/index.mjs",
|
|
6
6
|
"react-native": "dist/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"typecheck": "tsc --noEmit"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@aws-amplify/ui": "5.6.
|
|
34
|
+
"@aws-amplify/ui": "5.6.6",
|
|
35
35
|
"@xstate/react": "3.0.1",
|
|
36
36
|
"lodash": "4.17.21",
|
|
37
37
|
"xstate": "^4.33.6"
|