@webiny/app-admin-cognito 5.27.0-beta.0 → 5.28.0

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/index.js CHANGED
@@ -1,37 +1,67 @@
1
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
- import _objectSpread from "@babel/runtime/helpers/objectSpread2";
3
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.createAuthentication = void 0;
11
+
12
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
+
14
+ var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/regeneratorRuntime"));
15
+
16
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
17
+
18
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
19
+
20
+ var _react = _interopRequireWildcard(require("react"));
21
+
22
+ var _auth = require("@aws-amplify/auth");
23
+
24
+ var _reactHooks = require("@apollo/react-hooks");
25
+
26
+ var _apolloLinkContext = require("apollo-link-context");
27
+
28
+ var _plugins = require("@webiny/plugins");
29
+
30
+ var _ApolloLinkPlugin = require("@webiny/app/plugins/ApolloLinkPlugin");
31
+
32
+ var _Authenticator = require("@webiny/app-cognito-authenticator/Authenticator");
33
+
34
+ var _CheckingUser = _interopRequireDefault(require("./views/CheckingUser"));
35
+
36
+ var _SignIn = _interopRequireDefault(require("./views/SignIn"));
37
+
38
+ var _RequireNewPassword = _interopRequireDefault(require("./views/RequireNewPassword"));
39
+
40
+ var _ForgotPassword = _interopRequireDefault(require("./views/ForgotPassword"));
41
+
42
+ var _SetNewPassword = _interopRequireDefault(require("./views/SetNewPassword"));
43
+
44
+ var _SignedIn = _interopRequireDefault(require("./views/SignedIn"));
45
+
46
+ var _appSecurity = require("@webiny/app-security");
47
+
48
+ var _config = require("@webiny/app/config");
49
+
4
50
  var _excluded = ["getIdentityData", "onError"],
5
51
  _excluded2 = ["id", "displayName", "type", "permissions"];
6
- import _regeneratorRuntime from "@babel/runtime/regenerator";
7
- import React, { useCallback, useEffect } from "react";
8
- import { Auth } from "@aws-amplify/auth";
9
- import { useApolloClient } from "@apollo/react-hooks";
10
- import { setContext } from "apollo-link-context";
11
- import { plugins } from "@webiny/plugins";
12
- import { ApolloLinkPlugin } from "@webiny/app/plugins/ApolloLinkPlugin";
13
- import { Authenticator } from "@webiny/app-cognito-authenticator/Authenticator";
14
- import CheckingUser from "./views/CheckingUser";
15
- import SignIn from "./views/SignIn";
16
- import RequireNewPassword from "./views/RequireNewPassword";
17
- import ForgotPassword from "./views/ForgotPassword";
18
- import SetNewPassword from "./views/SetNewPassword";
19
- import SignedIn from "./views/SignedIn";
20
- import { useSecurity } from "@webiny/app-security";
21
- import { config as appConfig } from "@webiny/app/config";
22
52
 
23
53
  var createApolloLinkPlugin = function createApolloLinkPlugin() {
24
- return new ApolloLinkPlugin(function () {
25
- return setContext( /*#__PURE__*/function () {
26
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_, _ref) {
54
+ return new _ApolloLinkPlugin.ApolloLinkPlugin(function () {
55
+ return (0, _apolloLinkContext.setContext)( /*#__PURE__*/function () {
56
+ var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee(_, _ref) {
27
57
  var headers, user, idToken;
28
- return _regeneratorRuntime.wrap(function _callee$(_context) {
58
+ return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
29
59
  while (1) {
30
60
  switch (_context.prev = _context.next) {
31
61
  case 0:
32
62
  headers = _ref.headers;
33
63
  _context.next = 3;
34
- return Auth.currentSession();
64
+ return _auth.Auth.currentSession();
35
65
 
36
66
  case 3:
37
67
  user = _context.sent;
@@ -58,7 +88,7 @@ var createApolloLinkPlugin = function createApolloLinkPlugin() {
58
88
 
59
89
  case 9:
60
90
  return _context.abrupt("return", {
61
- headers: _objectSpread(_objectSpread({}, headers), {}, {
91
+ headers: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, headers), {}, {
62
92
  Authorization: "Bearer ".concat(idToken.getJwtToken())
63
93
  })
64
94
  });
@@ -79,14 +109,15 @@ var createApolloLinkPlugin = function createApolloLinkPlugin() {
79
109
  };
80
110
 
81
111
  var defaultOptions = {
82
- region: appConfig.getKey("USER_POOL_REGION", process.env.REACT_APP_USER_POOL_REGION),
83
- userPoolId: appConfig.getKey("USER_POOL_ID", process.env.REACT_APP_USER_POOL_ID),
84
- userPoolWebClientId: appConfig.getKey("USER_POOL_WEB_CLIENT_ID", process.env.REACT_APP_USER_POOL_WEB_CLIENT_ID)
112
+ region: _config.config.getKey("USER_POOL_REGION", process.env.REACT_APP_USER_POOL_REGION),
113
+ userPoolId: _config.config.getKey("USER_POOL_ID", process.env.REACT_APP_USER_POOL_ID),
114
+ userPoolWebClientId: _config.config.getKey("USER_POOL_WEB_CLIENT_ID", process.env.REACT_APP_USER_POOL_WEB_CLIENT_ID)
85
115
  };
86
- export var createAuthentication = function createAuthentication(_ref3) {
116
+
117
+ var createAuthentication = function createAuthentication(_ref3) {
87
118
  var getIdentityData = _ref3.getIdentityData,
88
119
  onError = _ref3.onError,
89
- config = _objectWithoutProperties(_ref3, _excluded);
120
+ config = (0, _objectWithoutProperties2.default)(_ref3, _excluded);
90
121
 
91
122
  /**
92
123
  * TODO @ts-refactor
@@ -95,20 +126,21 @@ export var createAuthentication = function createAuthentication(_ref3) {
95
126
  Object.keys(config).forEach(function (key) {
96
127
  return config[key] === undefined && delete config[key];
97
128
  });
98
- Auth.configure(_objectSpread(_objectSpread({}, defaultOptions), config));
129
+
130
+ _auth.Auth.configure((0, _objectSpread2.default)((0, _objectSpread2.default)({}, defaultOptions), config));
99
131
 
100
132
  var Authentication = function Authentication(props) {
101
133
  var children = props.children;
102
134
 
103
- var _useSecurity = useSecurity(),
135
+ var _useSecurity = (0, _appSecurity.useSecurity)(),
104
136
  setIdentity = _useSecurity.setIdentity;
105
137
 
106
- var client = useApolloClient();
107
- var onToken = useCallback( /*#__PURE__*/function () {
108
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(token) {
138
+ var client = (0, _reactHooks.useApolloClient)();
139
+ var onToken = (0, _react.useCallback)( /*#__PURE__*/function () {
140
+ var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2(token) {
109
141
  var payload, logout, _yield$getIdentityDat, id, displayName, type, permissions, data;
110
142
 
111
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
143
+ return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
112
144
  while (1) {
113
145
  switch (_context2.prev = _context2.next) {
114
146
  case 0:
@@ -126,8 +158,8 @@ export var createAuthentication = function createAuthentication(_ref3) {
126
158
  displayName = _yield$getIdentityDat.displayName;
127
159
  type = _yield$getIdentityDat.type;
128
160
  permissions = _yield$getIdentityDat.permissions;
129
- data = _objectWithoutProperties(_yield$getIdentityDat, _excluded2);
130
- setIdentity(_objectSpread(_objectSpread({
161
+ data = (0, _objectWithoutProperties2.default)(_yield$getIdentityDat, _excluded2);
162
+ setIdentity((0, _objectSpread2.default)((0, _objectSpread2.default)({
131
163
  id: id,
132
164
  displayName: displayName,
133
165
  type: type,
@@ -163,13 +195,15 @@ export var createAuthentication = function createAuthentication(_ref3) {
163
195
  return _ref4.apply(this, arguments);
164
196
  };
165
197
  }(), []);
166
- useEffect(function () {
167
- plugins.register(createApolloLinkPlugin());
198
+ (0, _react.useEffect)(function () {
199
+ _plugins.plugins.register(createApolloLinkPlugin());
168
200
  }, []);
169
- return /*#__PURE__*/React.createElement(Authenticator, {
201
+ return /*#__PURE__*/_react.default.createElement(_Authenticator.Authenticator, {
170
202
  onToken: onToken
171
- }, /*#__PURE__*/React.createElement(CheckingUser, null), /*#__PURE__*/React.createElement(SignIn, null), /*#__PURE__*/React.createElement(RequireNewPassword, null), /*#__PURE__*/React.createElement(ForgotPassword, null), /*#__PURE__*/React.createElement(SetNewPassword, null), /*#__PURE__*/React.createElement(SignedIn, null, children));
203
+ }, /*#__PURE__*/_react.default.createElement(_CheckingUser.default, null), /*#__PURE__*/_react.default.createElement(_SignIn.default, null), /*#__PURE__*/_react.default.createElement(_RequireNewPassword.default, null), /*#__PURE__*/_react.default.createElement(_ForgotPassword.default, null), /*#__PURE__*/_react.default.createElement(_SetNewPassword.default, null), /*#__PURE__*/_react.default.createElement(_SignedIn.default, null, children));
172
204
  };
173
205
 
174
206
  return Authentication;
175
- };
207
+ };
208
+
209
+ exports.createAuthentication = createAuthentication;
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.tsx"],"names":["React","useCallback","useEffect","Auth","useApolloClient","setContext","plugins","ApolloLinkPlugin","Authenticator","CheckingUser","SignIn","RequireNewPassword","ForgotPassword","SetNewPassword","SignedIn","useSecurity","config","appConfig","createApolloLinkPlugin","_","headers","currentSession","user","idToken","getIdToken","Authorization","getJwtToken","defaultOptions","region","getKey","process","env","REACT_APP_USER_POOL_REGION","userPoolId","REACT_APP_USER_POOL_ID","userPoolWebClientId","REACT_APP_USER_POOL_WEB_CLIENT_ID","createAuthentication","getIdentityData","onError","Object","keys","forEach","key","undefined","configure","Authentication","props","children","setIdentity","client","onToken","token","payload","logout","id","displayName","type","permissions","data","console","log","error","register"],"mappings":";;;;;;AAAA,OAAOA,KAAP,IAAgBC,WAAhB,EAA6BC,SAA7B,QAA8C,OAA9C;AACA,SAASC,IAAT,QAAqB,mBAArB;AAGA,SAASC,eAAT,QAAgC,qBAAhC;AACA,SAASC,UAAT,QAA2B,q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AA,WAJQ,yBAIRA,WAJQ;AAIKC,gBAAAA,IAJL,yBAIKA,IAJL;AAIWC,gBAAAA,WAJX,yBAIWA,WAJX;AAI2BC,gBAAAA,IAJ3B;AASpBV,gBAAAA,WAAW;AACPM,kBAAAA,EAAE,EAAFA,EADO;AAEPC,kBAAAA,WAAW,EAAXA,WAFO;AAGPC,kBAAAA,IAAI,EAAJA,IAHO;AAIPC,kBAAAA,WAAW,EAAXA;AAJO,mBAKJC,IALI;AAMPL,kBAAAA,MAAM,EACFA,MAAM,IACL,YAAM;AACH,2BAAO,KAAK,CAAZ;AACH;AAVE,mBAAX;AAToB;AAAA;;AAAA;AAAA;AAAA;AAsBpBM,gBAAAA,OAAO,CAACC,GAAR,CAAY,OAAZ;;AACA,oBAAI,OAAOtB,OAAP,KAAmB,UAAvB,EAAmC;AAC/BA,kBAAAA,OAAO,cAAP;AACH,iBAFD,MAEO;AACHqB,kBAAAA,OAAO,CAACE,KAAR;AACH;;AA3BmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OAAD;;AAAA;AAAA;AAAA;AAAA,SA6BxB,EA7BwB,CAA3B;AA+BA5D,IAAAA,SAAS,CAAC,YAAM;AACZI,MAAAA,OAAO,CAACyD,QAAR,CAAiB7C,sBAAsB,EAAvC;AACH,KAFQ,EAEN,EAFM,CAAT;AAIA,wBACI,oBAAC,aAAD;AAAe,MAAA,OAAO,EAAEiC;AAAxB,oBACI,oBAAC,YAAD,OADJ,eAEI,oBAAC,MAAD,OAFJ,eAGI,oBAAC,kBAAD,OAHJ,eAII,oBAAC,cAAD,OAJJ,eAKI,oBAAC,cAAD,OALJ,eAMI,oBAAC,QAAD,QAAWH,QAAX,CANJ,CADJ;AAUH,GAlDD;;AAoDA,SAAOF,cAAP;AACH,CAjEM","sourcesContent":["import React, { useCallback, useEffect } from \"react\";\nimport { Auth } from \"@aws-amplify/auth\";\nimport { AuthOptions } from \"@aws-amplify/auth/lib-esm/types\";\nimport ApolloClient from \"apollo-client\";\nimport { useApolloClient } from \"@apollo/react-hooks\";\nimport { setContext } from \"apollo-link-context\";\nimport { plugins } from \"@webiny/plugins\";\nimport { ApolloLinkPlugin } from \"@webiny/app/plugins/ApolloLinkPlugin\";\nimport { CognitoIdToken } from \"@webiny/app-cognito-authenticator/types\";\nimport { Authenticator } from \"@webiny/app-cognito-authenticator/Authenticator\";\nimport CheckingUser from \"~/views/CheckingUser\";\nimport SignIn from \"~/views/SignIn\";\nimport RequireNewPassword from \"~/views/RequireNewPassword\";\nimport ForgotPassword from \"~/views/ForgotPassword\";\nimport SetNewPassword from \"~/views/SetNewPassword\";\nimport SignedIn from \"~/views/SignedIn\";\nimport { useSecurity } from \"@webiny/app-security\";\nimport { config as appConfig } from \"@webiny/app/config\";\n\nconst createApolloLinkPlugin = (): ApolloLinkPlugin => {\n return new ApolloLinkPlugin(() => {\n return setContext(async (_, { headers }) => {\n const user = await Auth.currentSession();\n const idToken = user.getIdToken();\n\n if (!idToken) {\n return { headers };\n }\n\n // If \"Authorization\" header is already set, don't overwrite it.\n if (headers && headers.Authorization) {\n return { headers };\n }\n\n return {\n headers: {\n ...headers,\n Authorization: `Bearer ${idToken.getJwtToken()}`\n }\n };\n });\n });\n};\n\nconst defaultOptions = {\n region: appConfig.getKey(\"USER_POOL_REGION\", process.env.REACT_APP_USER_POOL_REGION),\n userPoolId: appConfig.getKey(\"USER_POOL_ID\", process.env.REACT_APP_USER_POOL_ID),\n userPoolWebClientId: appConfig.getKey(\n \"USER_POOL_WEB_CLIENT_ID\",\n process.env.REACT_APP_USER_POOL_WEB_CLIENT_ID\n )\n};\n\nexport interface AuthenticationProps {\n children: React.ReactNode;\n}\n\nexport interface AuthenticationFactoryConfig extends AuthOptions {\n onError?(error: Error): void;\n getIdentityData(params: {\n client: ApolloClient<any>;\n payload: { [key: string]: any };\n }): Promise<{ [key: string]: any }>;\n}\n\ninterface AuthenticationFactory {\n (params: AuthenticationFactoryConfig): React.FC<AuthenticationProps>;\n}\nexport const createAuthentication: AuthenticationFactory = ({\n getIdentityData,\n onError,\n ...config\n}) => {\n /**\n * TODO @ts-refactor\n */\n // @ts-ignore\n Object.keys(config).forEach(key => config[key] === undefined && delete config[key]);\n Auth.configure({ ...defaultOptions, ...config });\n\n const Authentication: React.FC<AuthenticationProps> = props => {\n const { children } = props;\n const { setIdentity } = useSecurity();\n const client = useApolloClient();\n\n const onToken = useCallback(async (token: CognitoIdToken) => {\n const { payload, logout } = token;\n\n try {\n const { id, displayName, type, permissions, ...data } = await getIdentityData({\n client,\n payload\n });\n\n setIdentity({\n id,\n displayName,\n type,\n permissions,\n ...data,\n logout:\n logout ||\n (() => {\n return void 0;\n })\n });\n } catch (err) {\n console.log(\"ERROR\", err);\n if (typeof onError === \"function\") {\n onError(err);\n } else {\n console.error(err);\n }\n }\n }, []);\n\n useEffect(() => {\n plugins.register(createApolloLinkPlugin());\n }, []);\n\n return (\n <Authenticator onToken={onToken}>\n <CheckingUser />\n <SignIn />\n <RequireNewPassword />\n <ForgotPassword />\n <SetNewPassword />\n <SignedIn>{children}</SignedIn>\n </Authenticator>\n );\n };\n\n return Authentication;\n};\n"]}
1
+ {"version":3,"names":["createApolloLinkPlugin","ApolloLinkPlugin","setContext","_","headers","Auth","currentSession","user","idToken","getIdToken","Authorization","getJwtToken","defaultOptions","region","appConfig","getKey","process","env","REACT_APP_USER_POOL_REGION","userPoolId","REACT_APP_USER_POOL_ID","userPoolWebClientId","REACT_APP_USER_POOL_WEB_CLIENT_ID","createAuthentication","getIdentityData","onError","config","Object","keys","forEach","key","undefined","configure","Authentication","props","children","useSecurity","setIdentity","client","useApolloClient","onToken","useCallback","token","payload","logout","id","displayName","type","permissions","data","console","log","error","useEffect","plugins","register"],"sources":["index.tsx"],"sourcesContent":["import React, { useCallback, useEffect } from \"react\";\nimport { Auth } from \"@aws-amplify/auth\";\nimport { AuthOptions } from \"@aws-amplify/auth/lib-esm/types\";\nimport ApolloClient from \"apollo-client\";\nimport { useApolloClient } from \"@apollo/react-hooks\";\nimport { setContext } from \"apollo-link-context\";\nimport { plugins } from \"@webiny/plugins\";\nimport { ApolloLinkPlugin } from \"@webiny/app/plugins/ApolloLinkPlugin\";\nimport { CognitoIdToken } from \"@webiny/app-cognito-authenticator/types\";\nimport { Authenticator } from \"@webiny/app-cognito-authenticator/Authenticator\";\nimport CheckingUser from \"~/views/CheckingUser\";\nimport SignIn from \"~/views/SignIn\";\nimport RequireNewPassword from \"~/views/RequireNewPassword\";\nimport ForgotPassword from \"~/views/ForgotPassword\";\nimport SetNewPassword from \"~/views/SetNewPassword\";\nimport SignedIn from \"~/views/SignedIn\";\nimport { useSecurity } from \"@webiny/app-security\";\nimport { config as appConfig } from \"@webiny/app/config\";\n\nconst createApolloLinkPlugin = (): ApolloLinkPlugin => {\n return new ApolloLinkPlugin(() => {\n return setContext(async (_, { headers }) => {\n const user = await Auth.currentSession();\n const idToken = user.getIdToken();\n\n if (!idToken) {\n return { headers };\n }\n\n // If \"Authorization\" header is already set, don't overwrite it.\n if (headers && headers.Authorization) {\n return { headers };\n }\n\n return {\n headers: {\n ...headers,\n Authorization: `Bearer ${idToken.getJwtToken()}`\n }\n };\n });\n });\n};\n\nconst defaultOptions = {\n region: appConfig.getKey(\"USER_POOL_REGION\", process.env.REACT_APP_USER_POOL_REGION),\n userPoolId: appConfig.getKey(\"USER_POOL_ID\", process.env.REACT_APP_USER_POOL_ID),\n userPoolWebClientId: appConfig.getKey(\n \"USER_POOL_WEB_CLIENT_ID\",\n process.env.REACT_APP_USER_POOL_WEB_CLIENT_ID\n )\n};\n\nexport interface AuthenticationProps {\n children: React.ReactNode;\n}\n\nexport interface AuthenticationFactoryConfig extends AuthOptions {\n onError?(error: Error): void;\n getIdentityData(params: {\n client: ApolloClient<any>;\n payload: { [key: string]: any };\n }): Promise<{ [key: string]: any }>;\n}\n\ninterface AuthenticationFactory {\n (params: AuthenticationFactoryConfig): React.FC<AuthenticationProps>;\n}\nexport const createAuthentication: AuthenticationFactory = ({\n getIdentityData,\n onError,\n ...config\n}) => {\n /**\n * TODO @ts-refactor\n */\n // @ts-ignore\n Object.keys(config).forEach(key => config[key] === undefined && delete config[key]);\n Auth.configure({ ...defaultOptions, ...config });\n\n const Authentication: React.FC<AuthenticationProps> = props => {\n const { children } = props;\n const { setIdentity } = useSecurity();\n const client = useApolloClient();\n\n const onToken = useCallback(async (token: CognitoIdToken) => {\n const { payload, logout } = token;\n\n try {\n const { id, displayName, type, permissions, ...data } = await getIdentityData({\n client,\n payload\n });\n\n setIdentity({\n id,\n displayName,\n type,\n permissions,\n ...data,\n logout:\n logout ||\n (() => {\n return void 0;\n })\n });\n } catch (err) {\n console.log(\"ERROR\", err);\n if (typeof onError === \"function\") {\n onError(err);\n } else {\n console.error(err);\n }\n }\n }, []);\n\n useEffect(() => {\n plugins.register(createApolloLinkPlugin());\n }, []);\n\n return (\n <Authenticator onToken={onToken}>\n <CheckingUser />\n <SignIn />\n <RequireNewPassword />\n <ForgotPassword />\n <SetNewPassword />\n <SignedIn>{children}</SignedIn>\n </Authenticator>\n );\n };\n\n return Authentication;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;AAEA,IAAMA,sBAAsB,GAAG,SAAzBA,sBAAyB,GAAwB;EACnD,OAAO,IAAIC,kCAAJ,CAAqB,YAAM;IAC9B,OAAO,IAAAC,6BAAA;MAAA,mGAAW,iBAAOC,CAAP;QAAA;QAAA;UAAA;YAAA;cAAA;gBAAYC,OAAZ,QAAYA,OAAZ;gBAAA;gBAAA,OACKC,UAAA,CAAKC,cAAL,EADL;;cAAA;gBACRC,IADQ;gBAERC,OAFQ,GAEED,IAAI,CAACE,UAAL,EAFF;;gBAAA,IAITD,OAJS;kBAAA;kBAAA;gBAAA;;gBAAA,iCAKH;kBAAEJ,OAAO,EAAPA;gBAAF,CALG;;cAAA;gBAAA,MASVA,OAAO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AAD,OAFJ,eAGI,6BAAC,2BAAD,OAHJ,eAII,6BAAC,uBAAD,OAJJ,eAKI,6BAAC,uBAAD,OALJ,eAMI,6BAAC,iBAAD,QAAWL,QAAX,CANJ,CADJ;EAUH,CAlDD;;EAoDA,OAAOF,cAAP;AACH,CAjEM"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/app-admin-cognito",
3
- "version": "5.27.0-beta.0",
3
+ "version": "5.28.0",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,16 +13,16 @@
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
15
  "@apollo/react-hooks": "3.1.5",
16
- "@aws-amplify/auth": "4.4.0",
16
+ "@aws-amplify/auth": "4.5.6",
17
17
  "@emotion/styled": "10.3.0",
18
- "@webiny/app": "5.27.0-beta.0",
19
- "@webiny/app-admin": "5.27.0-beta.0",
20
- "@webiny/app-cognito-authenticator": "5.27.0-beta.0",
21
- "@webiny/app-security": "5.27.0-beta.0",
22
- "@webiny/form": "5.27.0-beta.0",
23
- "@webiny/plugins": "5.27.0-beta.0",
24
- "@webiny/ui": "5.27.0-beta.0",
25
- "@webiny/validation": "5.27.0-beta.0",
18
+ "@webiny/app": "5.28.0",
19
+ "@webiny/app-admin": "5.28.0",
20
+ "@webiny/app-cognito-authenticator": "5.28.0",
21
+ "@webiny/app-security": "5.28.0",
22
+ "@webiny/form": "5.28.0",
23
+ "@webiny/plugins": "5.28.0",
24
+ "@webiny/ui": "5.28.0",
25
+ "@webiny/validation": "5.28.0",
26
26
  "apollo-client": "2.6.10",
27
27
  "apollo-link-context": "1.0.20",
28
28
  "emotion": "10.0.27",
@@ -37,8 +37,8 @@
37
37
  "@babel/preset-env": "^7.16.4",
38
38
  "@babel/preset-react": "^7.16.0",
39
39
  "@babel/preset-typescript": "^7.16.0",
40
- "@webiny/cli": "^5.27.0-beta.0",
41
- "@webiny/project-utils": "^5.27.0-beta.0",
40
+ "@webiny/cli": "^5.28.0",
41
+ "@webiny/project-utils": "^5.28.0",
42
42
  "babel-plugin-lodash": "^3.3.4",
43
43
  "rimraf": "^3.0.2",
44
44
  "ttypescript": "^1.5.12",
@@ -59,5 +59,5 @@
59
59
  ]
60
60
  }
61
61
  },
62
- "gitHead": "9e557dd294ae37cf84f17e0e8158c2ed16e2d415"
62
+ "gitHead": "9fd082a2e4a0e0116ee5a07e2a9ca385e8ac0173"
63
63
  }
package/types.js CHANGED
@@ -0,0 +1 @@
1
+ "use strict";
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":[""],"mappings":""}
@@ -1,14 +1,26 @@
1
- import React from "react";
2
- import { useAuthenticator } from "@webiny/app-cognito-authenticator/hooks/useAuthenticator";
3
- import { CircularProgress } from "@webiny/ui/Progress";
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _react = _interopRequireDefault(require("react"));
11
+
12
+ var _useAuthenticator2 = require("@webiny/app-cognito-authenticator/hooks/useAuthenticator");
13
+
14
+ var _Progress = require("@webiny/ui/Progress");
4
15
 
5
16
  var CheckingUser = function CheckingUser() {
6
- var _useAuthenticator = useAuthenticator(),
17
+ var _useAuthenticator = (0, _useAuthenticator2.useAuthenticator)(),
7
18
  checkingUser = _useAuthenticator.checkingUser;
8
19
 
9
- return checkingUser ? /*#__PURE__*/React.createElement(CircularProgress, {
20
+ return checkingUser ? /*#__PURE__*/_react.default.createElement(_Progress.CircularProgress, {
10
21
  label: "Verifying user..."
11
22
  }) : null;
12
23
  };
13
24
 
14
- export default CheckingUser;
25
+ var _default = CheckingUser;
26
+ exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"sources":["CheckingUser.tsx"],"names":["React","useAuthenticator","CircularProgress","CheckingUser","checkingUser"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,gBAAT,QAAiC,0DAAjC;AACA,SAASC,gBAAT,QAAiC,qBAAjC;;AAEA,IAAMC,YAAsB,GAAG,SAAzBA,YAAyB,GAAM;AACjC,0BAAyBF,gBAAgB,EAAzC;AAAA,MAAQG,YAAR,qBAAQA,YAAR;;AAEA,SAAOA,YAAY,gBAAG,oBAAC,gBAAD;AAAkB,IAAA,KAAK,EAAE;AAAzB,IAAH,GAAsD,IAAzE;AACH,CAJD;;AAMA,eAAeD,YAAf","sourcesContent":["import React from \"react\";\nimport { useAuthenticator } from \"@webiny/app-cognito-authenticator/hooks/useAuthenticator\";\nimport { CircularProgress } from \"@webiny/ui/Progress\";\n\nconst CheckingUser: React.FC = () => {\n const { checkingUser } = useAuthenticator();\n\n return checkingUser ? <CircularProgress label={\"Verifying user...\"} /> : null;\n};\n\nexport default CheckingUser;\n"]}
1
+ {"version":3,"names":["CheckingUser","useAuthenticator","checkingUser"],"sources":["CheckingUser.tsx"],"sourcesContent":["import React from \"react\";\nimport { useAuthenticator } from \"@webiny/app-cognito-authenticator/hooks/useAuthenticator\";\nimport { CircularProgress } from \"@webiny/ui/Progress\";\n\nconst CheckingUser: React.FC = () => {\n const { checkingUser } = useAuthenticator();\n\n return checkingUser ? <CircularProgress label={\"Verifying user...\"} /> : null;\n};\n\nexport default CheckingUser;\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEA,IAAMA,YAAsB,GAAG,SAAzBA,YAAyB,GAAM;EACjC,wBAAyB,IAAAC,mCAAA,GAAzB;EAAA,IAAQC,YAAR,qBAAQA,YAAR;;EAEA,OAAOA,YAAY,gBAAG,6BAAC,0BAAD;IAAkB,KAAK,EAAE;EAAzB,EAAH,GAAsD,IAAzE;AACH,CAJD;;eAMeF,Y"}
@@ -1,25 +1,49 @@
1
- import * as React from "react";
2
- import { Form } from "@webiny/form";
3
- import { validation } from "@webiny/validation";
4
- import { ButtonPrimary, ButtonDefault } from "@webiny/ui/Button";
5
- import { Input } from "@webiny/ui/Input";
6
- import { Grid, Cell } from "@webiny/ui/Grid";
7
- import { Typography } from "@webiny/ui/Typography";
8
- import { Alert } from "@webiny/ui/Alert";
9
- import { Elevation } from "@webiny/ui/Elevation";
10
- import StateContainer from "./StateContainer";
11
- import { alignRight, InnerContent, Title } from "./StyledComponents";
12
- import { CircularProgress } from "@webiny/ui/Progress";
13
- import { useAuthenticator } from "@webiny/app-cognito-authenticator/hooks/useAuthenticator";
14
- import { useForgotPassword } from "@webiny/app-cognito-authenticator/hooks/useForgotPassword";
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.default = void 0;
11
+
12
+ var React = _interopRequireWildcard(require("react"));
13
+
14
+ var _form = require("@webiny/form");
15
+
16
+ var _validation = require("@webiny/validation");
17
+
18
+ var _Button = require("@webiny/ui/Button");
19
+
20
+ var _Input = require("@webiny/ui/Input");
21
+
22
+ var _Grid = require("@webiny/ui/Grid");
23
+
24
+ var _Typography = require("@webiny/ui/Typography");
25
+
26
+ var _Alert = require("@webiny/ui/Alert");
27
+
28
+ var _Elevation = require("@webiny/ui/Elevation");
29
+
30
+ var _StateContainer = _interopRequireDefault(require("./StateContainer"));
31
+
32
+ var _StyledComponents = require("./StyledComponents");
33
+
34
+ var _Progress = require("@webiny/ui/Progress");
35
+
36
+ var _useAuthenticator2 = require("@webiny/app-cognito-authenticator/hooks/useAuthenticator");
37
+
38
+ var _useForgotPassword2 = require("@webiny/app-cognito-authenticator/hooks/useForgotPassword");
15
39
 
16
40
  var ForgotPassword = function ForgotPassword() {
17
- var _useAuthenticator = useAuthenticator(),
41
+ var _useAuthenticator = (0, _useAuthenticator2.useAuthenticator)(),
18
42
  checkingUser = _useAuthenticator.checkingUser,
19
43
  authData = _useAuthenticator.authData,
20
44
  changeState = _useAuthenticator.changeState;
21
45
 
22
- var _useForgotPassword = useForgotPassword(),
46
+ var _useForgotPassword = (0, _useForgotPassword2.useForgotPassword)(),
23
47
  loading = _useForgotPassword.loading,
24
48
  codeSent = _useForgotPassword.codeSent,
25
49
  shouldRender = _useForgotPassword.shouldRender,
@@ -35,7 +59,7 @@ var ForgotPassword = function ForgotPassword() {
35
59
  _ref$username = _ref.username,
36
60
  username = _ref$username === void 0 ? "" : _ref$username;
37
61
 
38
- return /*#__PURE__*/React.createElement(StateContainer, null, /*#__PURE__*/React.createElement(Form, {
62
+ return /*#__PURE__*/React.createElement(_StateContainer.default, null, /*#__PURE__*/React.createElement(_form.Form, {
39
63
  data: {
40
64
  username: username
41
65
  },
@@ -52,53 +76,53 @@ var ForgotPassword = function ForgotPassword() {
52
76
  var Bind = _ref3.Bind,
53
77
  submit = _ref3.submit,
54
78
  data = _ref3.data;
55
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Elevation, {
79
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Elevation.Elevation, {
56
80
  z: 2
57
- }, /*#__PURE__*/React.createElement(InnerContent, null, loading && /*#__PURE__*/React.createElement(CircularProgress, null), /*#__PURE__*/React.createElement(Title, null, /*#__PURE__*/React.createElement("h1", null, /*#__PURE__*/React.createElement(Typography, {
81
+ }, /*#__PURE__*/React.createElement(_StyledComponents.InnerContent, null, loading && /*#__PURE__*/React.createElement(_Progress.CircularProgress, null), /*#__PURE__*/React.createElement(_StyledComponents.Title, null, /*#__PURE__*/React.createElement("h1", null, /*#__PURE__*/React.createElement(_Typography.Typography, {
58
82
  use: "headline4"
59
- }, "Password Recovery")), /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement(Typography, {
83
+ }, "Password Recovery")), /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement(_Typography.Typography, {
60
84
  use: "subtitle2"
61
- }, "request a password reset code"))), error && /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Cell, {
85
+ }, "request a password reset code"))), error && /*#__PURE__*/React.createElement(_Grid.Grid, null, /*#__PURE__*/React.createElement(_Grid.Cell, {
62
86
  span: 12
63
- }, /*#__PURE__*/React.createElement(Alert, {
87
+ }, /*#__PURE__*/React.createElement(_Alert.Alert, {
64
88
  title: "Something went wrong",
65
89
  type: "danger"
66
- }, error))), !codeSent ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Cell, {
90
+ }, error))), !codeSent ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Grid.Grid, null, /*#__PURE__*/React.createElement(_Grid.Cell, {
67
91
  span: 12
68
92
  }, /*#__PURE__*/React.createElement(Bind, {
69
93
  name: "username",
70
- validators: validation.create("required"),
94
+ validators: _validation.validation.create("required"),
71
95
  beforeChange: function beforeChange(val, cb) {
72
96
  return cb(val.toLowerCase());
73
97
  }
74
- }, /*#__PURE__*/React.createElement(Input, {
98
+ }, /*#__PURE__*/React.createElement(_Input.Input, {
75
99
  label: "Email",
76
100
  description: "A reset code will be sent to your email."
77
- })))), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Cell, {
101
+ })))), /*#__PURE__*/React.createElement(_Grid.Grid, null, /*#__PURE__*/React.createElement(_Grid.Cell, {
78
102
  span: 12,
79
- className: alignRight
80
- }, /*#__PURE__*/React.createElement(ButtonPrimary, {
103
+ className: _StyledComponents.alignRight
104
+ }, /*#__PURE__*/React.createElement(_Button.ButtonPrimary, {
81
105
  onClick: function onClick(ev) {
82
106
  submit(ev);
83
107
  }
84
- }, "Send me the code")))) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Cell, {
108
+ }, "Send me the code")))) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Grid.Grid, null, /*#__PURE__*/React.createElement(_Grid.Cell, {
85
109
  span: 12
86
- }, /*#__PURE__*/React.createElement(Typography, {
110
+ }, /*#__PURE__*/React.createElement(_Typography.Typography, {
87
111
  use: "body1"
88
- }, "We have sent you a code to reset your password!", /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("br", null), "Click the \"Resend code\" button below to resend the code in case you haven't received it the first time."))), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Cell, {
112
+ }, "We have sent you a code to reset your password!", /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("br", null), "Click the \"Resend code\" button below to resend the code in case you haven't received it the first time."))), /*#__PURE__*/React.createElement(_Grid.Grid, null, /*#__PURE__*/React.createElement(_Grid.Cell, {
89
113
  span: 12,
90
- className: alignRight
91
- }, /*#__PURE__*/React.createElement(ButtonDefault, {
114
+ className: _StyledComponents.alignRight
115
+ }, /*#__PURE__*/React.createElement(_Button.ButtonDefault, {
92
116
  onClick: function onClick() {
93
117
  requestCode({
94
118
  username: data.username
95
119
  });
96
120
  }
97
- }, "Resend code"), /*#__PURE__*/React.createElement(ButtonPrimary, {
121
+ }, "Resend code"), /*#__PURE__*/React.createElement(_Button.ButtonPrimary, {
98
122
  onClick: function onClick(ev) {
99
123
  submit(ev);
100
124
  }
101
- }, "I got the code!")))))), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Cell, {
125
+ }, "I got the code!")))))), /*#__PURE__*/React.createElement(_Grid.Grid, null, /*#__PURE__*/React.createElement(_Grid.Cell, {
102
126
  span: 12,
103
127
  style: {
104
128
  textAlign: "center"
@@ -112,4 +136,5 @@ var ForgotPassword = function ForgotPassword() {
112
136
  }));
113
137
  };
114
138
 
115
- export default ForgotPassword;
139
+ var _default = ForgotPassword;
140
+ exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"sources":["ForgotPassword.tsx"],"names":["React","Form","validation","ButtonPrimary","ButtonDefault","Input","Grid","Cell","Typography","Alert","Elevation","StateContainer","alignRight","InnerContent","Title","CircularProgress","useAuthenticator","useForgotPassword","ForgotPassword","checkingUser","authData","changeState","loading","codeSent","shouldRender","setPassword","requestCode","error","username","Bind","submit","data","create","val","cb","toLowerCase","ev","textAlign"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,QAAqB,cAArB;AACA,SAASC,UAAT,QAA2B,oBAA3B;AACA,SAASC,aAAT,EAAwBC,aAAxB,QAA6C,mBAA7C;AACA,SAASC,KAAT,QAAsB,kBAAtB;AACA,SAASC,IAAT,EAAeC,IAAf,QAA2B,iBAA3B;AACA,SAASC,UAAT,QAA2B,uBAA3B;AACA,SAASC,KAAT,QAAsB,kBAAtB;AACA,SAASC,SAAT,QAA0B,sBAA1B;AACA,OAAOC,cAAP;AACA,SAASC,UAAT,EAAqBC,YAArB,EAAmCC,KAAnC;AACA,SAASC,gBAAT,QAAiC,qBAAjC;AACA,SAASC,gBAAT,QAAiC,0DAAjC;AACA,SAASC,iBAAT,QAAkC,2DAAlC;;AAEA,IAAMC,cAAwB,GAAG,SAA3BA,cAA2B,GAAM;AACnC,0BAAgDF,gBAAgB,EAAhE;AAAA,MAAQG,YAAR,qBAAQA,YAAR;AAAA,MAAsBC,QAAtB,qBAAsBA,QAAtB;AAAA,MAAgCC,WAAhC,qBAAgCA,WAAhC;;AACA,2BACIJ,iBAAiB,EADrB;AAAA,MAAQK,OAAR,sBAAQA,OAAR;AAAA,MAAiBC,QAAjB,sBAAiBA,QAAjB;AAAA,MAA2BC,YAA3B,sBAA2BA,YAA3B;AAAA,MAAyCC,WAAzC,sBAAyCA,WAAzC;AAAA,MAAsDC,WAAtD,sBAAsDA,WAAtD;AAAA,MAAmEC,KAAnE,sBAAmEA,KAAnE;;AAGA,MAAI,CAACH,YAAD,IAAiBL,YAArB,EAAmC;AAC/B,WAAO,IAA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AG,MAAA,IAAI,EAAE,GAAT;AAAc,MAAA,OAAO,EAAE;AAAA,eAAMhB,WAAW,CAAC,QAAD,CAAjB;AAAA;AAAvB,iBAFJ,CADJ,CA/FJ,CADH;AAAA,GAPL,CADJ,CADJ;AAsHH,CAjID;;AAmIA,eAAeH,cAAf","sourcesContent":["import * as React from \"react\";\nimport { Form } from \"@webiny/form\";\nimport { validation } from \"@webiny/validation\";\nimport { ButtonPrimary, ButtonDefault } from \"@webiny/ui/Button\";\nimport { Input } from \"@webiny/ui/Input\";\nimport { Grid, Cell } from \"@webiny/ui/Grid\";\nimport { Typography } from \"@webiny/ui/Typography\";\nimport { Alert } from \"@webiny/ui/Alert\";\nimport { Elevation } from \"@webiny/ui/Elevation\";\nimport StateContainer from \"./StateContainer\";\nimport { alignRight, InnerContent, Title } from \"./StyledComponents\";\nimport { CircularProgress } from \"@webiny/ui/Progress\";\nimport { useAuthenticator } from \"@webiny/app-cognito-authenticator/hooks/useAuthenticator\";\nimport { useForgotPassword } from \"@webiny/app-cognito-authenticator/hooks/useForgotPassword\";\n\nconst ForgotPassword: React.FC = () => {\n const { checkingUser, authData, changeState } = useAuthenticator();\n const { loading, codeSent, shouldRender, setPassword, requestCode, error } =\n useForgotPassword();\n\n if (!shouldRender || checkingUser) {\n return null;\n }\n\n const { username = \"\" } = authData || {};\n\n return (\n <StateContainer>\n <Form\n data={{ username }}\n onSubmit={({ username }) =>\n codeSent ? setPassword({ username }) : requestCode({ username })\n }\n submitOnEnter\n >\n {({ Bind, submit, data }) => (\n <>\n <Elevation z={2}>\n <InnerContent>\n {loading && <CircularProgress />}\n <Title>\n <h1>\n <Typography use=\"headline4\">Password Recovery</Typography>\n </h1>\n <p>\n <Typography use=\"subtitle2\">\n request a password reset code\n </Typography>\n </p>\n </Title>\n\n {error && (\n <Grid>\n <Cell span={12}>\n <Alert title={\"Something went wrong\"} type={\"danger\"}>\n {error}\n </Alert>\n </Cell>\n </Grid>\n )}\n\n {!codeSent ? (\n <>\n <Grid>\n <Cell span={12}>\n <Bind\n name=\"username\"\n validators={validation.create(\"required\")}\n beforeChange={(\n val: string,\n cb: (value: string) => void\n ) => cb(val.toLowerCase())}\n >\n <Input\n label={\"Email\"}\n description={\n \"A reset code will be sent to your email.\"\n }\n />\n </Bind>\n </Cell>\n </Grid>\n\n <Grid>\n <Cell span={12} className={alignRight}>\n <ButtonPrimary\n onClick={ev => {\n submit(ev);\n }}\n >\n {\"Send me the code\"}\n </ButtonPrimary>\n </Cell>\n </Grid>\n </>\n ) : (\n <>\n <Grid>\n <Cell span={12}>\n <Typography use=\"body1\">\n We have sent you a code to reset your password!\n <br />\n <br />\n Click the &quot;Resend code&quot; button below\n to resend the code in case you haven&apos;t\n received it the first time.\n </Typography>\n </Cell>\n </Grid>\n <Grid>\n <Cell span={12} className={alignRight}>\n <ButtonDefault\n onClick={() => {\n requestCode({ username: data.username });\n }}\n >\n {\"Resend code\"}\n </ButtonDefault>\n <ButtonPrimary\n onClick={ev => {\n submit(ev);\n }}\n >\n I got the code!\n </ButtonPrimary>\n </Cell>\n </Grid>\n </>\n )}\n </InnerContent>\n </Elevation>\n <Grid>\n <Cell span={12} style={{ textAlign: \"center\" }}>\n Want to sign in? {/* eslint-disable-next-line */}\n <a href={\"#\"} onClick={() => changeState(\"signIn\")}>\n Sign in\n </a>\n </Cell>\n </Grid>\n </>\n )}\n </Form>\n </StateContainer>\n );\n};\n\nexport default ForgotPassword;\n"]}
1
+ {"version":3,"names":["ForgotPassword","useAuthenticator","checkingUser","authData","changeState","useForgotPassword","loading","codeSent","shouldRender","setPassword","requestCode","error","username","Bind","submit","data","validation","create","val","cb","toLowerCase","alignRight","ev","textAlign"],"sources":["ForgotPassword.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { Form } from \"@webiny/form\";\nimport { validation } from \"@webiny/validation\";\nimport { ButtonPrimary, ButtonDefault } from \"@webiny/ui/Button\";\nimport { Input } from \"@webiny/ui/Input\";\nimport { Grid, Cell } from \"@webiny/ui/Grid\";\nimport { Typography } from \"@webiny/ui/Typography\";\nimport { Alert } from \"@webiny/ui/Alert\";\nimport { Elevation } from \"@webiny/ui/Elevation\";\nimport StateContainer from \"./StateContainer\";\nimport { alignRight, InnerContent, Title } from \"./StyledComponents\";\nimport { CircularProgress } from \"@webiny/ui/Progress\";\nimport { useAuthenticator } from \"@webiny/app-cognito-authenticator/hooks/useAuthenticator\";\nimport { useForgotPassword } from \"@webiny/app-cognito-authenticator/hooks/useForgotPassword\";\n\nconst ForgotPassword: React.FC = () => {\n const { checkingUser, authData, changeState } = useAuthenticator();\n const { loading, codeSent, shouldRender, setPassword, requestCode, error } =\n useForgotPassword();\n\n if (!shouldRender || checkingUser) {\n return null;\n }\n\n const { username = \"\" } = authData || {};\n\n return (\n <StateContainer>\n <Form\n data={{ username }}\n onSubmit={({ username }) =>\n codeSent ? setPassword({ username }) : requestCode({ username })\n }\n submitOnEnter\n >\n {({ Bind, submit, data }) => (\n <>\n <Elevation z={2}>\n <InnerContent>\n {loading && <CircularProgress />}\n <Title>\n <h1>\n <Typography use=\"headline4\">Password Recovery</Typography>\n </h1>\n <p>\n <Typography use=\"subtitle2\">\n request a password reset code\n </Typography>\n </p>\n </Title>\n\n {error && (\n <Grid>\n <Cell span={12}>\n <Alert title={\"Something went wrong\"} type={\"danger\"}>\n {error}\n </Alert>\n </Cell>\n </Grid>\n )}\n\n {!codeSent ? (\n <>\n <Grid>\n <Cell span={12}>\n <Bind\n name=\"username\"\n validators={validation.create(\"required\")}\n beforeChange={(\n val: string,\n cb: (value: string) => void\n ) => cb(val.toLowerCase())}\n >\n <Input\n label={\"Email\"}\n description={\n \"A reset code will be sent to your email.\"\n }\n />\n </Bind>\n </Cell>\n </Grid>\n\n <Grid>\n <Cell span={12} className={alignRight}>\n <ButtonPrimary\n onClick={ev => {\n submit(ev);\n }}\n >\n {\"Send me the code\"}\n </ButtonPrimary>\n </Cell>\n </Grid>\n </>\n ) : (\n <>\n <Grid>\n <Cell span={12}>\n <Typography use=\"body1\">\n We have sent you a code to reset your password!\n <br />\n <br />\n Click the &quot;Resend code&quot; button below\n to resend the code in case you haven&apos;t\n received it the first time.\n </Typography>\n </Cell>\n </Grid>\n <Grid>\n <Cell span={12} className={alignRight}>\n <ButtonDefault\n onClick={() => {\n requestCode({ username: data.username });\n }}\n >\n {\"Resend code\"}\n </ButtonDefault>\n <ButtonPrimary\n onClick={ev => {\n submit(ev);\n }}\n >\n I got the code!\n </ButtonPrimary>\n </Cell>\n </Grid>\n </>\n )}\n </InnerContent>\n </Elevation>\n <Grid>\n <Cell span={12} style={{ textAlign: \"center\" }}>\n Want to sign in? {/* eslint-disable-next-line */}\n <a href={\"#\"} onClick={() => changeState(\"signIn\")}>\n Sign in\n </a>\n </Cell>\n </Grid>\n </>\n )}\n </Form>\n </StateContainer>\n );\n};\n\nexport default ForgotPassword;\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA,IAAMA,cAAwB,GAAG,SAA3BA,cAA2B,GAAM;EACnC,wBAAgD,IAAAC,mCAAA,GAAhD;EAAA,IAAQC,YAAR,qBAAQA,YAAR;EAAA,IAAsBC,QAAtB,qBAAsBA,QAAtB;EAAA,IAAgCC,WAAhC,qBAAgCA,WAAhC;;EACA,yBACI,IAAAC,qCAAA,GADJ;EAAA,IAAQC,OAAR,sBAAQA,OAAR;EAAA,IAAiBC,QAAjB,sBAAiBA,QAAjB;EAAA,IAA2BC,YAA3B,sBAA2BA,YAA3B;EAAA,IAAyCC,WAAzC,sBAAyCA,WAAzC;EAAA,IAAsDC,WAAtD,sBAAsDA,WAAtD;EAAA,IAAmEC,KAAnE,sBAAmEA,KAAnE;;EAGA,IAAI,CAACH,YAAD,IAAiBN,YAArB,EAAmC;IAC/B,OAAO,IAAP;EACH;;EAED,WAA0BC,QAAQ,IAAI,EAAtC;EAAA,yBAAQS,QAAR;EAAA,IAAQA,Q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