@aws-amplify/ui-react-core 2.1.9 → 2.1.11
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.js → AuthenticatorContext.mjs} +0 -0
- package/dist/esm/Authenticator/context/{AuthenticatorProvider.js → AuthenticatorProvider.mjs} +3 -4
- package/dist/esm/Authenticator/hooks/{constants.js → constants.mjs} +0 -0
- package/dist/esm/Authenticator/hooks/useAuthenticator/{constants.js → constants.mjs} +0 -0
- package/dist/esm/Authenticator/hooks/useAuthenticator/{useAuthenticator.js → useAuthenticator.mjs} +11 -13
- package/dist/esm/Authenticator/hooks/useAuthenticator/{utils.js → utils.mjs} +5 -8
- package/dist/esm/Authenticator/hooks/useAuthenticatorInitMachine/{useAuthenticatorInitMachine.js → useAuthenticatorInitMachine.mjs} +1 -1
- package/dist/esm/Authenticator/hooks/useAuthenticatorRoute/{constants.js → constants.mjs} +1 -0
- package/dist/esm/Authenticator/hooks/useAuthenticatorRoute/{useAuthenticatorRoute.js → useAuthenticatorRoute.mjs} +2 -2
- package/dist/esm/Authenticator/hooks/useAuthenticatorRoute/{utils.js → utils.mjs} +6 -7
- package/dist/esm/Authenticator/hooks/{utils.js → utils.mjs} +1 -1
- package/dist/esm/InAppMessaging/context/InAppMessagingContext/{InAppMessagingContext.js → InAppMessagingContext.mjs} +0 -0
- package/dist/esm/InAppMessaging/context/InAppMessagingProvider/{InAppMessagingProvider.js → InAppMessagingProvider.mjs} +3 -4
- package/dist/esm/InAppMessaging/hooks/useInAppMessaging/{useInAppMessaging.js → useInAppMessaging.mjs} +1 -2
- package/dist/esm/InAppMessaging/hooks/useMessage/{useMessage.js → useMessage.mjs} +4 -4
- package/dist/esm/InAppMessaging/hooks/useMessage/{utils.js → utils.mjs} +1 -1
- package/dist/esm/InAppMessaging/utils/{handleMessageAction.js → handleMessageAction.mjs} +1 -1
- package/dist/esm/components/RenderNothing/{RenderNothing.js → RenderNothing.mjs} +0 -0
- package/dist/esm/hooks/{useHasValueUpdated.js → useHasValueUpdated.mjs} +2 -2
- package/dist/esm/hooks/{usePreviousValue.js → usePreviousValue.mjs} +0 -0
- package/dist/esm/{index.js → index.mjs} +14 -14
- package/dist/esm/node_modules/tslib/{tslib.es6.js → tslib.es6.mjs} +0 -0
- package/dist/esm/utils/{index.js → index.mjs} +3 -4
- package/dist/index.js +19 -29
- package/dist/types/Authenticator/hooks/types.d.ts +26 -26
- package/dist/types/Authenticator/hooks/useAuthenticator/types.d.ts +4 -3
- package/dist/types/Authenticator/hooks/useAuthenticatorRoute/utils.d.ts +1 -1
- package/dist/types/components/RenderNothing/RenderNothing.d.ts +1 -0
- package/package.json +4 -5
|
File without changes
|
package/dist/esm/Authenticator/context/{AuthenticatorProvider.js → AuthenticatorProvider.mjs}
RENAMED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useContext, useMemo, useEffect } from 'react';
|
|
1
|
+
import React, { useContext, useMemo, useEffect } from 'react';
|
|
3
2
|
import { useInterpret } from '@xstate/react';
|
|
4
3
|
import { createAuthenticatorMachine, listenToAuthHub } from '@aws-amplify/ui';
|
|
5
|
-
import { AuthenticatorContext } from './AuthenticatorContext.
|
|
4
|
+
import { AuthenticatorContext } from './AuthenticatorContext.mjs';
|
|
6
5
|
|
|
7
6
|
function AuthenticatorProvider({ children, }) {
|
|
8
7
|
/**
|
|
@@ -20,7 +19,7 @@ function AuthenticatorProvider({ children, }) {
|
|
|
20
19
|
const unsubscribe = listenToAuthHub(activeService);
|
|
21
20
|
return unsubscribe;
|
|
22
21
|
}, [activeService]);
|
|
23
|
-
return (
|
|
22
|
+
return (React.createElement(AuthenticatorContext.Provider, { value: value }, children));
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
export { AuthenticatorProvider as default };
|
|
File without changes
|
|
File without changes
|
package/dist/esm/Authenticator/hooks/useAuthenticator/{useAuthenticator.js → useAuthenticator.mjs}
RENAMED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { __rest } from '../../../node_modules/tslib/tslib.es6.
|
|
2
|
-
import React, { useCallback
|
|
1
|
+
import { __rest } from '../../../node_modules/tslib/tslib.es6.mjs';
|
|
2
|
+
import React, { useCallback } from 'react';
|
|
3
3
|
import { useSelector } from '@xstate/react';
|
|
4
4
|
import { getServiceFacade } from '@aws-amplify/ui';
|
|
5
|
-
import '
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { getQRFields, getMachineFields, getTotpSecretCodeCallback, getComparator, defaultComparator } from './utils.js';
|
|
5
|
+
import { AuthenticatorContext } from '../../context/AuthenticatorContext.mjs';
|
|
6
|
+
import { USE_AUTHENTICATOR_ERROR } from './constants.mjs';
|
|
7
|
+
import { getQRFields, getMachineFields, getTotpSecretCodeCallback, getComparator, defaultComparator } from './utils.mjs';
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* [📖 Docs](https://ui.docs.amplify.aws/react/connected-components/authenticator/headless#useauthenticator-hook)
|
|
@@ -20,21 +19,20 @@ function useAuthenticator(selector) {
|
|
|
20
19
|
const xstateSelector = useCallback((state) => (Object.assign({}, getServiceFacade({ send, state }))), [send]);
|
|
21
20
|
const comparator = selector ? getComparator(selector) : defaultComparator;
|
|
22
21
|
const facade = useSelector(service, xstateSelector, comparator);
|
|
23
|
-
const { route, unverifiedContactMethods, user } = facade, rest = __rest(facade, ["route", "unverifiedContactMethods", "user"]);
|
|
22
|
+
const { route, totpSecretCode, unverifiedContactMethods, user } = facade, rest = __rest(facade, ["route", "totpSecretCode", "unverifiedContactMethods", "user"]);
|
|
24
23
|
// do not memoize output. `service.getSnapshot` reference remains stable preventing
|
|
25
24
|
// `fields` from updating with current form state on value changes
|
|
26
25
|
const serviceSnapshot = service.getSnapshot();
|
|
27
26
|
// legacy `QRFields` values only used for SetupTOTP page to retrieve issuer information, will be removed in future
|
|
28
|
-
const QRFields =
|
|
27
|
+
const QRFields = route === 'setupTOTP' ? getQRFields(serviceSnapshot) : null;
|
|
29
28
|
// legacy `formFields` values required until form state is removed from state machine
|
|
30
|
-
const fields =
|
|
31
|
-
return Object.assign(Object.assign({}, rest), {
|
|
29
|
+
const fields = getMachineFields(route, serviceSnapshot, unverifiedContactMethods);
|
|
30
|
+
return Object.assign(Object.assign({}, rest), { route,
|
|
31
|
+
totpSecretCode,
|
|
32
32
|
unverifiedContactMethods,
|
|
33
33
|
user,
|
|
34
34
|
/** @deprecated For internal use only */
|
|
35
|
-
fields,
|
|
36
|
-
/** @deprecated For internal use only */
|
|
37
|
-
QRFields });
|
|
35
|
+
fields, getTotpSecretCode: getTotpSecretCodeCallback(user), QRFields });
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
export { useAuthenticator as default };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { __awaiter } from '../../../node_modules/tslib/tslib.es6.
|
|
1
|
+
import { __awaiter } from '../../../node_modules/tslib/tslib.es6.mjs';
|
|
2
2
|
import { Auth } from 'aws-amplify';
|
|
3
|
-
import { getActorContext, getSortedFormFields } from '@aws-amplify/ui';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import { isComponentRouteKey } from '../utils.js';
|
|
3
|
+
import { getActorContext, getSortedFormFields, isString } from '@aws-amplify/ui';
|
|
4
|
+
import { areEmptyArrays, areEmptyObjects } from '../../../utils/index.mjs';
|
|
5
|
+
import { isComponentRouteKey } from '../utils.mjs';
|
|
7
6
|
|
|
8
7
|
const defaultComparator = () => false;
|
|
9
8
|
/**
|
|
@@ -31,9 +30,7 @@ const getComparator = (selector) => (currentFacade, nextFacade) => {
|
|
|
31
30
|
};
|
|
32
31
|
const getQRFields = (state) => {
|
|
33
32
|
var _a, _b, _c;
|
|
34
|
-
|
|
35
|
-
const QR = (_c = (_b = (_a = fields === null || fields === void 0 ? void 0 : fields.formFields) === null || _a === void 0 ? void 0 : _a.setupTOTP) === null || _b === void 0 ? void 0 : _b.QR) !== null && _c !== void 0 ? _c : {};
|
|
36
|
-
return Object.assign({}, QR);
|
|
33
|
+
return (Object.assign({}, (_c = (_b = (_a = getActorContext(state)) === null || _a === void 0 ? void 0 : _a.formFields) === null || _b === void 0 ? void 0 : _b.setupTOTP) === null || _c === void 0 ? void 0 : _c.QR));
|
|
37
34
|
};
|
|
38
35
|
const getTotpSecretCodeCallback = (user) => function getTotpSecretCode() {
|
|
39
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import useAuthenticator from '../useAuthenticator/useAuthenticator.
|
|
2
|
+
import useAuthenticator from '../useAuthenticator/useAuthenticator.mjs';
|
|
3
3
|
|
|
4
4
|
// only select `route` from machine context
|
|
5
5
|
const routeSelector = ({ route }) => [route];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
-
import useAuthenticator from '../useAuthenticator/useAuthenticator.
|
|
3
|
-
import { getRouteMachineSelector, resolveDefault, resolveVerifyUserRoute, resolveSignUpRoute, resolveSignInRoute, resolveSetupTOTPRoute, resolveResetPasswordRoute, resolveForceNewPasswordRoute, resolveConfirmVerifyUserRoute, resolveConfirmSignUpRoute, resolveConfirmSignInRoute, resolveConfirmResetPasswordRoute, routeSelector } from './utils.
|
|
2
|
+
import useAuthenticator from '../useAuthenticator/useAuthenticator.mjs';
|
|
3
|
+
import { getRouteMachineSelector, resolveDefault, resolveVerifyUserRoute, resolveSignUpRoute, resolveSignInRoute, resolveSetupTOTPRoute, resolveResetPasswordRoute, resolveForceNewPasswordRoute, resolveConfirmVerifyUserRoute, resolveConfirmSignUpRoute, resolveConfirmSignInRoute, resolveConfirmResetPasswordRoute, routeSelector } from './utils.mjs';
|
|
4
4
|
|
|
5
5
|
function useAuthenticatorRoute({ components, }) {
|
|
6
6
|
const { route } = useAuthenticator(routeSelector);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { __rest } from '../../../node_modules/tslib/tslib.es6.
|
|
2
|
-
import RenderNothing from '../../../components/RenderNothing/RenderNothing.
|
|
3
|
-
import { isComponentRouteKey } from '../utils.
|
|
4
|
-
import { MACHINE_PROP_KEYS, EVENT_HANDLER_KEY_MAP } from './constants.
|
|
1
|
+
import { __rest } from '../../../node_modules/tslib/tslib.es6.mjs';
|
|
2
|
+
import RenderNothing from '../../../components/RenderNothing/RenderNothing.mjs';
|
|
3
|
+
import { isComponentRouteKey } from '../utils.mjs';
|
|
4
|
+
import { MACHINE_PROP_KEYS, EVENT_HANDLER_KEY_MAP } from './constants.mjs';
|
|
5
5
|
|
|
6
6
|
// only select `route` from machine context
|
|
7
7
|
const routeSelector = ({ route }) => [route];
|
|
@@ -52,11 +52,10 @@ function resolveResetPasswordRoute(Component, props) {
|
|
|
52
52
|
props: Object.assign(Object.assign({}, Component), getConvertedMachineProps('resetPassword', props)),
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
|
-
function resolveSetupTOTPRoute(Component,
|
|
56
|
-
var { getTotpSecretCode } = _a, props = __rest(_a, ["getTotpSecretCode"]);
|
|
55
|
+
function resolveSetupTOTPRoute(Component, props) {
|
|
57
56
|
return {
|
|
58
57
|
Component,
|
|
59
|
-
props: Object.assign(Object.assign(
|
|
58
|
+
props: Object.assign(Object.assign({}, Component), getConvertedMachineProps('setupTOTP', props)),
|
|
60
59
|
};
|
|
61
60
|
}
|
|
62
61
|
function resolveSignInRoute(Component, props) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { COMPONENT_ROUTE_KEYS, COMPONENT_ROUTE_NAMES } from './constants.
|
|
1
|
+
import { COMPONENT_ROUTE_KEYS, COMPONENT_ROUTE_NAMES } from './constants.mjs';
|
|
2
2
|
|
|
3
3
|
const isComponentRouteKey = (route) => COMPONENT_ROUTE_KEYS.some((componentRoute) => componentRoute === route);
|
|
4
4
|
function resolveAuthenticatorComponents(defaults, overrides) {
|
|
File without changes
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useState, useEffect, useCallback, useMemo } from 'react';
|
|
1
|
+
import React, { useState, useEffect, useCallback, useMemo } from 'react';
|
|
3
2
|
import { Notifications } from '@aws-amplify/notifications';
|
|
4
|
-
import InAppMessagingContext from '../InAppMessagingContext/InAppMessagingContext.
|
|
3
|
+
import InAppMessagingContext from '../InAppMessagingContext/InAppMessagingContext.mjs';
|
|
5
4
|
|
|
6
5
|
const { InAppMessaging } = Notifications;
|
|
7
6
|
function InAppMessagingProvider({ children, }) {
|
|
@@ -20,7 +19,7 @@ function InAppMessagingProvider({ children, }) {
|
|
|
20
19
|
displayMessage: setMessage,
|
|
21
20
|
message,
|
|
22
21
|
}), [clearMessage, message]);
|
|
23
|
-
return (
|
|
22
|
+
return (React.createElement(InAppMessagingContext.Provider, { value: value }, children));
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
export { InAppMessagingProvider as default };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
|
-
import InAppMessagingContext from '../../context/InAppMessagingContext/InAppMessagingContext.
|
|
3
|
-
import 'react/jsx-runtime';
|
|
2
|
+
import InAppMessagingContext from '../../context/InAppMessagingContext/InAppMessagingContext.mjs';
|
|
4
3
|
import '@aws-amplify/notifications';
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ConsoleLogger } from '@aws-amplify/core';
|
|
2
2
|
import { InAppMessageInteractionEvent, Notifications } from '@aws-amplify/notifications';
|
|
3
|
-
import isNil from 'lodash/isNil';
|
|
4
|
-
import RenderNothing from '../../../components/RenderNothing/RenderNothing.
|
|
5
|
-
import useInAppMessaging from '../useInAppMessaging/useInAppMessaging.
|
|
6
|
-
import { getContentProps, getPositionProp } from './utils.
|
|
3
|
+
import isNil from 'lodash/isNil.js';
|
|
4
|
+
import RenderNothing from '../../../components/RenderNothing/RenderNothing.mjs';
|
|
5
|
+
import useInAppMessaging from '../useInAppMessaging/useInAppMessaging.mjs';
|
|
6
|
+
import { getContentProps, getPositionProp } from './utils.mjs';
|
|
7
7
|
|
|
8
8
|
const EMPTY_PROPS = Object.freeze({});
|
|
9
9
|
const logger = new ConsoleLogger('Notifications.InAppMessaging');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ConsoleLogger } from '@aws-amplify/core';
|
|
2
|
-
import isString from '
|
|
2
|
+
import { isString } from '@aws-amplify/ui';
|
|
3
3
|
|
|
4
4
|
const logger = new ConsoleLogger('Notifications.InAppMessaging');
|
|
5
5
|
const handleMessageAction = ({ action, handleMessageLinkAction, url, }) => {
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { isUndefined } from '@aws-amplify/ui';
|
|
2
|
+
import usePreviousValue from './usePreviousValue.mjs';
|
|
3
3
|
|
|
4
4
|
function useHasValueUpdated(value, ignoreFirstRender = false) {
|
|
5
5
|
const previous = usePreviousValue(value);
|
|
File without changes
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export { default as AuthenticatorProvider } from './Authenticator/context/AuthenticatorProvider.
|
|
2
|
-
import './Authenticator/context/AuthenticatorContext.
|
|
3
|
-
export { default as useAuthenticator } from './Authenticator/hooks/useAuthenticator/useAuthenticator.
|
|
4
|
-
export { default as useAuthenticatorRoute } from './Authenticator/hooks/useAuthenticatorRoute/useAuthenticatorRoute.
|
|
5
|
-
export { default as useAuthenticatorInitMachine } from './Authenticator/hooks/useAuthenticatorInitMachine/useAuthenticatorInitMachine.
|
|
6
|
-
export { isComponentRouteKey as isAuthenticatorComponentRouteKey, resolveAuthenticatorComponents } from './Authenticator/hooks/utils.
|
|
7
|
-
export { default as useInAppMessaging } from './InAppMessaging/hooks/useInAppMessaging/useInAppMessaging.
|
|
8
|
-
export { default as useMessage } from './InAppMessaging/hooks/useMessage/useMessage.
|
|
9
|
-
import './InAppMessaging/context/InAppMessagingContext/InAppMessagingContext.
|
|
10
|
-
export { default as InAppMessagingProvider } from './InAppMessaging/context/InAppMessagingProvider/InAppMessagingProvider.
|
|
11
|
-
export { default as handleMessageAction } from './InAppMessaging/utils/handleMessageAction.
|
|
12
|
-
export { default as usePreviousValue } from './hooks/usePreviousValue.
|
|
13
|
-
export { default as useHasValueUpdated } from './hooks/useHasValueUpdated.
|
|
14
|
-
export { templateJoin } from './utils/index.
|
|
1
|
+
export { default as AuthenticatorProvider } from './Authenticator/context/AuthenticatorProvider.mjs';
|
|
2
|
+
import './Authenticator/context/AuthenticatorContext.mjs';
|
|
3
|
+
export { default as useAuthenticator } from './Authenticator/hooks/useAuthenticator/useAuthenticator.mjs';
|
|
4
|
+
export { default as useAuthenticatorRoute } from './Authenticator/hooks/useAuthenticatorRoute/useAuthenticatorRoute.mjs';
|
|
5
|
+
export { default as useAuthenticatorInitMachine } from './Authenticator/hooks/useAuthenticatorInitMachine/useAuthenticatorInitMachine.mjs';
|
|
6
|
+
export { isComponentRouteKey as isAuthenticatorComponentRouteKey, resolveAuthenticatorComponents } from './Authenticator/hooks/utils.mjs';
|
|
7
|
+
export { default as useInAppMessaging } from './InAppMessaging/hooks/useInAppMessaging/useInAppMessaging.mjs';
|
|
8
|
+
export { default as useMessage } from './InAppMessaging/hooks/useMessage/useMessage.mjs';
|
|
9
|
+
import './InAppMessaging/context/InAppMessagingContext/InAppMessagingContext.mjs';
|
|
10
|
+
export { default as InAppMessagingProvider } from './InAppMessaging/context/InAppMessagingProvider/InAppMessagingProvider.mjs';
|
|
11
|
+
export { default as handleMessageAction } from './InAppMessaging/utils/handleMessageAction.mjs';
|
|
12
|
+
export { default as usePreviousValue } from './hooks/usePreviousValue.mjs';
|
|
13
|
+
export { default as useHasValueUpdated } from './hooks/useHasValueUpdated.mjs';
|
|
14
|
+
export { templateJoin } from './utils/index.mjs';
|
|
File without changes
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import isEmpty from 'lodash/isEmpty';
|
|
2
|
-
import isObject from '
|
|
3
|
-
import isString from 'lodash/isString';
|
|
1
|
+
import isEmpty from 'lodash/isEmpty.js';
|
|
2
|
+
import { isString, isObject } from '@aws-amplify/ui';
|
|
4
3
|
|
|
5
4
|
function isEmptyArray(value) {
|
|
6
5
|
return Array.isArray(value) && isEmpty(value);
|
|
@@ -9,7 +8,7 @@ function areEmptyArrays(...values) {
|
|
|
9
8
|
return values.every(isEmptyArray);
|
|
10
9
|
}
|
|
11
10
|
function isEmptyObject(value) {
|
|
12
|
-
return isObject(value) &&
|
|
11
|
+
return isObject(value) && isEmpty(value);
|
|
13
12
|
}
|
|
14
13
|
function areEmptyObjects(...values) {
|
|
15
14
|
return values.every(isEmptyObject);
|
package/dist/index.js
CHANGED
|
@@ -2,27 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
6
5
|
var React = require('react');
|
|
7
6
|
var react = require('@xstate/react');
|
|
8
7
|
var ui = require('@aws-amplify/ui');
|
|
9
8
|
var awsAmplify = require('aws-amplify');
|
|
10
|
-
var
|
|
11
|
-
var isEmpty = require('lodash/isEmpty');
|
|
12
|
-
var isObject = require('lodash/isObject');
|
|
9
|
+
var isEmpty = require('lodash/isEmpty.js');
|
|
13
10
|
var notifications = require('@aws-amplify/notifications');
|
|
14
11
|
var core = require('@aws-amplify/core');
|
|
15
|
-
var isNil = require('lodash/isNil');
|
|
16
|
-
var isUndefined = require('lodash/isUndefined');
|
|
12
|
+
var isNil = require('lodash/isNil.js');
|
|
17
13
|
|
|
18
14
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
15
|
|
|
20
16
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
21
|
-
var isString__default = /*#__PURE__*/_interopDefaultLegacy(isString);
|
|
22
17
|
var isEmpty__default = /*#__PURE__*/_interopDefaultLegacy(isEmpty);
|
|
23
|
-
var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
|
|
24
18
|
var isNil__default = /*#__PURE__*/_interopDefaultLegacy(isNil);
|
|
25
|
-
var isUndefined__default = /*#__PURE__*/_interopDefaultLegacy(isUndefined);
|
|
26
19
|
|
|
27
20
|
/**
|
|
28
21
|
* AuthenticatorContext serves static reference to the auth machine service.
|
|
@@ -47,7 +40,7 @@ function AuthenticatorProvider({ children, }) {
|
|
|
47
40
|
const unsubscribe = ui.listenToAuthHub(activeService);
|
|
48
41
|
return unsubscribe;
|
|
49
42
|
}, [activeService]);
|
|
50
|
-
return (
|
|
43
|
+
return (React__default["default"].createElement(AuthenticatorContext.Provider, { value: value }, children));
|
|
51
44
|
}
|
|
52
45
|
|
|
53
46
|
/******************************************************************************
|
|
@@ -96,13 +89,13 @@ function areEmptyArrays(...values) {
|
|
|
96
89
|
return values.every(isEmptyArray);
|
|
97
90
|
}
|
|
98
91
|
function isEmptyObject(value) {
|
|
99
|
-
return
|
|
92
|
+
return ui.isObject(value) && isEmpty__default["default"](value);
|
|
100
93
|
}
|
|
101
94
|
function areEmptyObjects(...values) {
|
|
102
95
|
return values.every(isEmptyObject);
|
|
103
96
|
}
|
|
104
97
|
function templateJoin(values, template) {
|
|
105
|
-
return values.reduce((acc, curr) => `${acc}${
|
|
98
|
+
return values.reduce((acc, curr) => `${acc}${ui.isString(curr) ? template(curr) : ''}`, '');
|
|
106
99
|
}
|
|
107
100
|
|
|
108
101
|
const COMPONENT_ROUTE_KEYS = [
|
|
@@ -177,9 +170,7 @@ const getComparator = (selector) => (currentFacade, nextFacade) => {
|
|
|
177
170
|
};
|
|
178
171
|
const getQRFields = (state) => {
|
|
179
172
|
var _a, _b, _c;
|
|
180
|
-
|
|
181
|
-
const QR = (_c = (_b = (_a = fields === null || fields === void 0 ? void 0 : fields.formFields) === null || _a === void 0 ? void 0 : _a.setupTOTP) === null || _b === void 0 ? void 0 : _b.QR) !== null && _c !== void 0 ? _c : {};
|
|
182
|
-
return Object.assign({}, QR);
|
|
173
|
+
return (Object.assign({}, (_c = (_b = (_a = ui.getActorContext(state)) === null || _a === void 0 ? void 0 : _a.formFields) === null || _b === void 0 ? void 0 : _b.setupTOTP) === null || _c === void 0 ? void 0 : _c.QR));
|
|
183
174
|
};
|
|
184
175
|
const getTotpSecretCodeCallback = (user) => function getTotpSecretCode() {
|
|
185
176
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -190,7 +181,7 @@ const flattenFormFields = (fields) => fields.flatMap(([name, options]) => (Objec
|
|
|
190
181
|
const convertContactMethodsToFields = (unverifiedContactMethods) => {
|
|
191
182
|
return (unverifiedContactMethods &&
|
|
192
183
|
Object.entries(unverifiedContactMethods).map(([name, value]) => {
|
|
193
|
-
const valueIsString =
|
|
184
|
+
const valueIsString = ui.isString(value);
|
|
194
185
|
if (!valueIsString || !name) {
|
|
195
186
|
return {};
|
|
196
187
|
}
|
|
@@ -223,21 +214,20 @@ function useAuthenticator(selector) {
|
|
|
223
214
|
const xstateSelector = React.useCallback((state) => (Object.assign({}, ui.getServiceFacade({ send, state }))), [send]);
|
|
224
215
|
const comparator = selector ? getComparator(selector) : defaultComparator;
|
|
225
216
|
const facade = react.useSelector(service, xstateSelector, comparator);
|
|
226
|
-
const { route, unverifiedContactMethods, user } = facade, rest = __rest(facade, ["route", "unverifiedContactMethods", "user"]);
|
|
217
|
+
const { route, totpSecretCode, unverifiedContactMethods, user } = facade, rest = __rest(facade, ["route", "totpSecretCode", "unverifiedContactMethods", "user"]);
|
|
227
218
|
// do not memoize output. `service.getSnapshot` reference remains stable preventing
|
|
228
219
|
// `fields` from updating with current form state on value changes
|
|
229
220
|
const serviceSnapshot = service.getSnapshot();
|
|
230
221
|
// legacy `QRFields` values only used for SetupTOTP page to retrieve issuer information, will be removed in future
|
|
231
|
-
const QRFields =
|
|
222
|
+
const QRFields = route === 'setupTOTP' ? getQRFields(serviceSnapshot) : null;
|
|
232
223
|
// legacy `formFields` values required until form state is removed from state machine
|
|
233
|
-
const fields =
|
|
234
|
-
return Object.assign(Object.assign({}, rest), {
|
|
224
|
+
const fields = getMachineFields(route, serviceSnapshot, unverifiedContactMethods);
|
|
225
|
+
return Object.assign(Object.assign({}, rest), { route,
|
|
226
|
+
totpSecretCode,
|
|
235
227
|
unverifiedContactMethods,
|
|
236
228
|
user,
|
|
237
229
|
/** @deprecated For internal use only */
|
|
238
|
-
fields,
|
|
239
|
-
/** @deprecated For internal use only */
|
|
240
|
-
QRFields });
|
|
230
|
+
fields, getTotpSecretCode: getTotpSecretCodeCallback(user), QRFields });
|
|
241
231
|
}
|
|
242
232
|
|
|
243
233
|
/**
|
|
@@ -301,6 +291,7 @@ const SIGN_UP_MACHINE_KEYS = [
|
|
|
301
291
|
const SETUP_TOTP_MACHINE_KEYS = [
|
|
302
292
|
...COMMON_ROUTE_MACHINE_KEYS,
|
|
303
293
|
'toSignIn',
|
|
294
|
+
'totpSecretCode',
|
|
304
295
|
];
|
|
305
296
|
const VERIFY_USER_MACHINE_KEYS = [
|
|
306
297
|
...COMMON_ROUTE_MACHINE_KEYS,
|
|
@@ -368,11 +359,10 @@ function resolveResetPasswordRoute(Component, props) {
|
|
|
368
359
|
props: Object.assign(Object.assign({}, Component), getConvertedMachineProps('resetPassword', props)),
|
|
369
360
|
};
|
|
370
361
|
}
|
|
371
|
-
function resolveSetupTOTPRoute(Component,
|
|
372
|
-
var { getTotpSecretCode } = _a, props = __rest(_a, ["getTotpSecretCode"]);
|
|
362
|
+
function resolveSetupTOTPRoute(Component, props) {
|
|
373
363
|
return {
|
|
374
364
|
Component,
|
|
375
|
-
props: Object.assign(Object.assign(
|
|
365
|
+
props: Object.assign(Object.assign({}, Component), getConvertedMachineProps('setupTOTP', props)),
|
|
376
366
|
};
|
|
377
367
|
}
|
|
378
368
|
function resolveSignInRoute(Component, props) {
|
|
@@ -481,7 +471,7 @@ function InAppMessagingProvider({ children, }) {
|
|
|
481
471
|
displayMessage: setMessage,
|
|
482
472
|
message,
|
|
483
473
|
}), [clearMessage, message]);
|
|
484
|
-
return (
|
|
474
|
+
return (React__default["default"].createElement(InAppMessagingContext.Provider, { value: value }, children));
|
|
485
475
|
}
|
|
486
476
|
|
|
487
477
|
/**
|
|
@@ -610,7 +600,7 @@ const logger = new core.ConsoleLogger('Notifications.InAppMessaging');
|
|
|
610
600
|
const handleMessageAction = ({ action, handleMessageLinkAction, url, }) => {
|
|
611
601
|
logger.info(`Handle action: ${action}`);
|
|
612
602
|
if (action === 'LINK' || action === 'DEEP_LINK') {
|
|
613
|
-
if (!
|
|
603
|
+
if (!ui.isString(url)) {
|
|
614
604
|
logger.warn(`url must be of type string. Received: ${url}`);
|
|
615
605
|
return;
|
|
616
606
|
}
|
|
@@ -630,7 +620,7 @@ function usePreviousValue(value) {
|
|
|
630
620
|
|
|
631
621
|
function useHasValueUpdated(value, ignoreFirstRender = false) {
|
|
632
622
|
const previous = usePreviousValue(value);
|
|
633
|
-
const shouldIgnoreChange =
|
|
623
|
+
const shouldIgnoreChange = ui.isUndefined(previous) && ignoreFirstRender;
|
|
634
624
|
if (shouldIgnoreChange) {
|
|
635
625
|
return false;
|
|
636
626
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { AuthChallengeName, AuthenticatorServiceFacade, LegacyFormFieldOptions } from '@aws-amplify/ui';
|
|
3
|
+
import { UseAuthenticator } from './useAuthenticator';
|
|
3
4
|
export declare type AuthenticatorRouteComponentKey = 'confirmResetPassword' | 'confirmSignIn' | 'confirmSignUp' | 'confirmVerifyUser' | 'forceNewPassword' | 'resetPassword' | 'setupTOTP' | 'signIn' | 'signUp' | 'verifyUser';
|
|
4
5
|
export declare type AuthenticatorLegacyField = LegacyFormFieldOptions;
|
|
5
6
|
export declare type AuthenticatorLegacyFields = AuthenticatorLegacyField[];
|
|
@@ -10,7 +11,6 @@ export declare type AuthenticatorLegacyFields = AuthenticatorLegacyField[];
|
|
|
10
11
|
export declare type AuthenticatorMachineContext = AuthenticatorServiceFacade;
|
|
11
12
|
export declare type AuthenticatorMachineContextKey = keyof AuthenticatorMachineContext;
|
|
12
13
|
export declare type AuthenticatorRouteComponentName = Capitalize<AuthenticatorRouteComponentKey>;
|
|
13
|
-
export declare type GetTotpSecretCode = () => Promise<string>;
|
|
14
14
|
interface HeaderProps {
|
|
15
15
|
children?: React.ReactNode;
|
|
16
16
|
}
|
|
@@ -18,8 +18,8 @@ interface FooterProps {
|
|
|
18
18
|
children?: React.ReactNode;
|
|
19
19
|
}
|
|
20
20
|
declare type FormFieldsProps = {
|
|
21
|
-
isPending:
|
|
22
|
-
validationErrors?:
|
|
21
|
+
isPending: UseAuthenticator['isPending'];
|
|
22
|
+
validationErrors?: UseAuthenticator['validationErrors'];
|
|
23
23
|
};
|
|
24
24
|
export declare type FooterComponent<Props = {}> = React.ComponentType<FooterProps & Props>;
|
|
25
25
|
export declare type FormFieldsComponent<FieldType, Props = {}> = React.ComponentType<FormFieldsProps & {
|
|
@@ -35,55 +35,55 @@ export interface ComponentSlots<FieldType = {}> {
|
|
|
35
35
|
* Common component prop types used for both RWA and RNA implementations
|
|
36
36
|
*/
|
|
37
37
|
export declare type CommonRouteProps = {
|
|
38
|
-
error?:
|
|
39
|
-
isPending:
|
|
40
|
-
handleBlur:
|
|
41
|
-
handleChange:
|
|
42
|
-
handleSubmit:
|
|
38
|
+
error?: UseAuthenticator['error'];
|
|
39
|
+
isPending: UseAuthenticator['isPending'];
|
|
40
|
+
handleBlur: UseAuthenticator['updateBlur'];
|
|
41
|
+
handleChange: UseAuthenticator['updateForm'];
|
|
42
|
+
handleSubmit: UseAuthenticator['submitForm'];
|
|
43
43
|
};
|
|
44
44
|
/**
|
|
45
45
|
* Base Route component props
|
|
46
46
|
*/
|
|
47
47
|
export declare type ConfirmResetPasswordBaseProps<FieldType = {}> = {
|
|
48
|
-
resendCode:
|
|
49
|
-
validationErrors?:
|
|
48
|
+
resendCode: UseAuthenticator['resendCode'];
|
|
49
|
+
validationErrors?: UseAuthenticator['validationErrors'];
|
|
50
50
|
} & CommonRouteProps & ComponentSlots<FieldType>;
|
|
51
51
|
export declare type ConfirmSignInBaseProps<FieldType = {}> = {
|
|
52
52
|
challengeName: AuthChallengeName;
|
|
53
|
-
toSignIn:
|
|
53
|
+
toSignIn: UseAuthenticator['toSignIn'];
|
|
54
54
|
} & CommonRouteProps & ComponentSlots<FieldType>;
|
|
55
55
|
export declare type ConfirmSignUpBaseProps<FieldType = {}> = {
|
|
56
|
-
codeDeliveryDetails:
|
|
57
|
-
resendCode:
|
|
56
|
+
codeDeliveryDetails: UseAuthenticator['codeDeliveryDetails'];
|
|
57
|
+
resendCode: UseAuthenticator['resendCode'];
|
|
58
58
|
} & CommonRouteProps & ComponentSlots<FieldType>;
|
|
59
59
|
export declare type ConfirmVerifyUserProps<FieldType = {}> = {
|
|
60
|
-
skipVerification:
|
|
60
|
+
skipVerification: UseAuthenticator['skipVerification'];
|
|
61
61
|
} & CommonRouteProps & ComponentSlots<FieldType>;
|
|
62
62
|
export declare type ForceResetPasswordBaseProps<FieldType = {}> = {
|
|
63
|
-
toSignIn:
|
|
64
|
-
validationErrors?:
|
|
63
|
+
toSignIn: UseAuthenticator['toSignIn'];
|
|
64
|
+
validationErrors?: UseAuthenticator['validationErrors'];
|
|
65
65
|
} & CommonRouteProps & ComponentSlots<FieldType>;
|
|
66
66
|
export declare type ResetPasswordBaseProps<FieldType = {}> = {
|
|
67
|
-
toSignIn:
|
|
67
|
+
toSignIn: UseAuthenticator['toSignIn'];
|
|
68
68
|
} & CommonRouteProps & ComponentSlots<FieldType>;
|
|
69
69
|
export declare type SetupTOTPBaseProps<FieldType = {}> = {
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
toSignIn: UseAuthenticator['toSignIn'];
|
|
71
|
+
totpSecretCode: UseAuthenticator['totpSecretCode'];
|
|
72
72
|
} & CommonRouteProps & ComponentSlots<FieldType>;
|
|
73
73
|
export declare type SignInBaseProps<FieldType = {}> = {
|
|
74
74
|
hideSignUp?: boolean;
|
|
75
|
-
toFederatedSignIn:
|
|
76
|
-
toResetPassword:
|
|
77
|
-
toSignUp:
|
|
75
|
+
toFederatedSignIn: UseAuthenticator['toFederatedSignIn'];
|
|
76
|
+
toResetPassword: UseAuthenticator['toResetPassword'];
|
|
77
|
+
toSignUp: UseAuthenticator['toSignUp'];
|
|
78
78
|
} & CommonRouteProps & ComponentSlots<FieldType>;
|
|
79
79
|
export declare type SignUpBaseProps<FieldType = {}> = {
|
|
80
80
|
hideSignIn?: boolean;
|
|
81
|
-
toFederatedSignIn:
|
|
82
|
-
toSignIn:
|
|
83
|
-
validationErrors?:
|
|
81
|
+
toFederatedSignIn: UseAuthenticator['toFederatedSignIn'];
|
|
82
|
+
toSignIn: UseAuthenticator['toSignIn'];
|
|
83
|
+
validationErrors?: UseAuthenticator['validationErrors'];
|
|
84
84
|
} & CommonRouteProps & ComponentSlots<FieldType>;
|
|
85
85
|
export declare type VerifyUserProps<FieldType = {}> = {
|
|
86
|
-
skipVerification:
|
|
86
|
+
skipVerification: UseAuthenticator['skipVerification'];
|
|
87
87
|
} & CommonRouteProps & ComponentSlots<FieldType>;
|
|
88
88
|
export interface DefaultProps<FieldType = {}> {
|
|
89
89
|
ConfirmSignIn: ConfirmSignInBaseProps<FieldType>;
|
|
@@ -15,14 +15,15 @@ export declare type AuthenticatorLegacyFields = LegacyFormFieldOptions[];
|
|
|
15
15
|
*/
|
|
16
16
|
export declare type UseAuthenticatorSelector = (context: AuthenticatorMachineContext) => AuthenticatorMachineContext[AuthenticatorMachineContextKey][];
|
|
17
17
|
export interface UseAuthenticator extends AuthenticatorServiceFacade {
|
|
18
|
+
/** @deprecated For internal use only */
|
|
19
|
+
fields: AuthenticatorLegacyFields;
|
|
20
|
+
/** @deprecated For internal use only */
|
|
18
21
|
getTotpSecretCode: () => Promise<string>;
|
|
19
22
|
/** @deprecated For internal use only */
|
|
20
23
|
QRFields: {
|
|
21
24
|
totpIssuer?: string;
|
|
22
25
|
totpUsername?: string;
|
|
23
|
-
};
|
|
24
|
-
/** @deprecated For internal use only */
|
|
25
|
-
fields: AuthenticatorLegacyFields;
|
|
26
|
+
} | null;
|
|
26
27
|
}
|
|
27
28
|
export declare type Comparator = (currentMachineContext: AuthenticatorMachineContext, nextMachineContext: AuthenticatorMachineContext) => boolean;
|
|
28
29
|
export {};
|
|
@@ -10,7 +10,7 @@ export declare function resolveConfirmSignUpRoute<FieldType = {}>(Component: Def
|
|
|
10
10
|
export declare function resolveConfirmVerifyUserRoute<FieldType = {}>(Component: Defaults<FieldType>['ConfirmVerifyUser'], props: UseAuthenticator): UseAuthenticatorRoute<'ConfirmVerifyUser', FieldType>;
|
|
11
11
|
export declare function resolveForceNewPasswordRoute<FieldType = {}>(Component: Defaults<FieldType>['ForceNewPassword'], props: UseAuthenticator): UseAuthenticatorRoute<'ForceNewPassword', FieldType>;
|
|
12
12
|
export declare function resolveResetPasswordRoute<FieldType = {}>(Component: Defaults<FieldType>['ResetPassword'], props: UseAuthenticator): UseAuthenticatorRoute<'ResetPassword', FieldType>;
|
|
13
|
-
export declare function resolveSetupTOTPRoute<FieldType = {}>(Component: Defaults<FieldType>['SetupTOTP'],
|
|
13
|
+
export declare function resolveSetupTOTPRoute<FieldType = {}>(Component: Defaults<FieldType>['SetupTOTP'], props: UseAuthenticator): UseAuthenticatorRoute<'SetupTOTP', FieldType>;
|
|
14
14
|
export declare function resolveSignInRoute<FieldType = {}>(Component: Defaults<FieldType>['SignIn'], props: UseAuthenticator): UseAuthenticatorRoute<'SignIn', FieldType>;
|
|
15
15
|
export declare function resolveSignUpRoute<FieldType = {}>(Component: Defaults<FieldType>['SignUp'], props: UseAuthenticator): UseAuthenticatorRoute<'SignUp', FieldType>;
|
|
16
16
|
export declare function resolveVerifyUserRoute<FieldType = {}>(Component: Defaults<FieldType>['VerifyUser'], props: UseAuthenticator): UseAuthenticatorRoute<'VerifyUser', FieldType>;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/ui-react-core",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.11",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
|
-
"module": "dist/esm/index.
|
|
5
|
+
"module": "dist/esm/index.mjs",
|
|
6
6
|
"react-native": "dist/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
-
"import": "./dist/esm/index.
|
|
9
|
+
"import": "./dist/esm/index.mjs",
|
|
10
10
|
"require": "./dist/index.js"
|
|
11
11
|
},
|
|
12
12
|
"./package.json": "./package.json"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"test:watch": "yarn test --watch"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@aws-amplify/ui": "5.5.
|
|
31
|
+
"@aws-amplify/ui": "5.5.3",
|
|
32
32
|
"@xstate/react": "3.0.1",
|
|
33
33
|
"lodash": "4.17.21",
|
|
34
34
|
"xstate": "^4.33.6"
|
|
@@ -38,7 +38,6 @@
|
|
|
38
38
|
"react": ">= 16.14.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@rollup/plugin-commonjs": "^22.0.1",
|
|
42
41
|
"@rollup/plugin-typescript": "^8.3.1",
|
|
43
42
|
"@testing-library/react": "^12.0.0",
|
|
44
43
|
"@testing-library/react-hooks": "^7.0.2",
|