@webiny/app-admin-cognito 0.0.0-unstable.611c5af35e → 0.0.0-unstable.615a930a68

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,33 +1,57 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
4
5
  var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
6
+
5
7
  Object.defineProperty(exports, "__esModule", {
6
8
  value: true
7
9
  });
8
10
  exports.createAuthentication = void 0;
11
+
9
12
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
+
10
14
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
15
+
11
16
  var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/regeneratorRuntime"));
17
+
12
18
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
19
+
13
20
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
21
+
14
22
  var _react = _interopRequireWildcard(require("react"));
23
+
15
24
  var _auth = require("@aws-amplify/auth");
25
+
16
26
  var _reactHooks = require("@apollo/react-hooks");
27
+
17
28
  var _apolloLinkContext = require("apollo-link-context");
29
+
18
30
  var _plugins = require("@webiny/plugins");
31
+
19
32
  var _ApolloLinkPlugin = require("@webiny/app/plugins/ApolloLinkPlugin");
33
+
20
34
  var _Authenticator = require("@webiny/app-cognito-authenticator/Authenticator");
35
+
21
36
  var _SignIn = _interopRequireDefault(require("./views/SignIn"));
37
+
22
38
  var _RequireNewPassword = _interopRequireDefault(require("./views/RequireNewPassword"));
39
+
23
40
  var _ForgotPassword = _interopRequireDefault(require("./views/ForgotPassword"));
41
+
24
42
  var _SetNewPassword = _interopRequireDefault(require("./views/SetNewPassword"));
43
+
25
44
  var _SignedIn = _interopRequireDefault(require("./views/SignedIn"));
45
+
26
46
  var _appSecurity = require("@webiny/app-security");
47
+
27
48
  var _config = require("@webiny/app/config");
49
+
28
50
  var _LoggingIn = _interopRequireDefault(require("./views/LoggingIn"));
51
+
29
52
  var _excluded = ["getIdentityData", "onError"],
30
- _excluded2 = ["id", "displayName", "type", "permissions"];
53
+ _excluded2 = ["id", "displayName", "type", "permissions"];
54
+
31
55
  var createApolloLinkPlugin = function createApolloLinkPlugin() {
32
56
  return new _ApolloLinkPlugin.ApolloLinkPlugin(function () {
33
57
  return (0, _apolloLinkContext.setContext)( /*#__PURE__*/function () {
@@ -40,30 +64,37 @@ var createApolloLinkPlugin = function createApolloLinkPlugin() {
40
64
  headers = _ref.headers;
41
65
  _context.next = 3;
42
66
  return _auth.Auth.currentSession();
67
+
43
68
  case 3:
44
69
  user = _context.sent;
45
70
  idToken = user.getIdToken();
71
+
46
72
  if (idToken) {
47
73
  _context.next = 7;
48
74
  break;
49
75
  }
76
+
50
77
  return _context.abrupt("return", {
51
78
  headers: headers
52
79
  });
80
+
53
81
  case 7:
54
82
  if (!(headers && headers.Authorization)) {
55
83
  _context.next = 9;
56
84
  break;
57
85
  }
86
+
58
87
  return _context.abrupt("return", {
59
88
  headers: headers
60
89
  });
90
+
61
91
  case 9:
62
92
  return _context.abrupt("return", {
63
93
  headers: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, headers), {}, {
64
94
  Authorization: "Bearer ".concat(idToken.getJwtToken())
65
95
  })
66
96
  });
97
+
67
98
  case 10:
68
99
  case "end":
69
100
  return _context.stop();
@@ -71,21 +102,25 @@ var createApolloLinkPlugin = function createApolloLinkPlugin() {
71
102
  }
72
103
  }, _callee);
73
104
  }));
105
+
74
106
  return function (_x, _x2) {
75
107
  return _ref2.apply(this, arguments);
76
108
  };
77
109
  }());
78
110
  });
79
111
  };
112
+
80
113
  var defaultOptions = {
81
114
  region: _config.config.getKey("USER_POOL_REGION", process.env.REACT_APP_USER_POOL_REGION),
82
115
  userPoolId: _config.config.getKey("USER_POOL_ID", process.env.REACT_APP_USER_POOL_ID),
83
116
  userPoolWebClientId: _config.config.getKey("USER_POOL_WEB_CLIENT_ID", process.env.REACT_APP_USER_POOL_WEB_CLIENT_ID)
84
117
  };
118
+
85
119
  var createAuthentication = function createAuthentication(_ref3) {
86
120
  var getIdentityData = _ref3.getIdentityData,
87
- onError = _ref3.onError,
88
- config = (0, _objectWithoutProperties2.default)(_ref3, _excluded);
121
+ onError = _ref3.onError,
122
+ config = (0, _objectWithoutProperties2.default)(_ref3, _excluded);
123
+
89
124
  /**
90
125
  * TODO @ts-refactor
91
126
  */
@@ -93,19 +128,25 @@ var createAuthentication = function createAuthentication(_ref3) {
93
128
  Object.keys(config).forEach(function (key) {
94
129
  return config[key] === undefined && delete config[key];
95
130
  });
131
+
96
132
  _auth.Auth.configure((0, _objectSpread2.default)((0, _objectSpread2.default)({}, defaultOptions), config));
133
+
97
134
  var Authentication = function Authentication(props) {
98
135
  var children = props.children;
136
+
99
137
  var _useState = (0, _react.useState)(false),
100
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
101
- loadingIdentity = _useState2[0],
102
- setLoadingIdentity = _useState2[1];
138
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
139
+ loadingIdentity = _useState2[0],
140
+ setLoadingIdentity = _useState2[1];
141
+
103
142
  var _useSecurity = (0, _appSecurity.useSecurity)(),
104
- setIdentity = _useSecurity.setIdentity;
143
+ setIdentity = _useSecurity.setIdentity;
144
+
105
145
  var client = (0, _reactHooks.useApolloClient)();
106
146
  var onToken = (0, _react.useCallback)( /*#__PURE__*/function () {
107
147
  var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2(token) {
108
148
  var payload, logout, _yield$getIdentityDat, id, displayName, type, permissions, data;
149
+
109
150
  return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
110
151
  while (1) {
111
152
  switch (_context2.prev = _context2.next) {
@@ -118,6 +159,7 @@ var createAuthentication = function createAuthentication(_ref3) {
118
159
  client: client,
119
160
  payload: payload
120
161
  });
162
+
121
163
  case 5:
122
164
  _yield$getIdentityDat = _context2.sent;
123
165
  id = _yield$getIdentityDat.id;
@@ -137,19 +179,23 @@ var createAuthentication = function createAuthentication(_ref3) {
137
179
  }));
138
180
  _context2.next = 18;
139
181
  break;
182
+
140
183
  case 14:
141
184
  _context2.prev = 14;
142
185
  _context2.t0 = _context2["catch"](2);
143
186
  console.log("ERROR", _context2.t0);
187
+
144
188
  if (typeof onError === "function") {
145
189
  onError(_context2.t0);
146
190
  } else {
147
191
  console.error(_context2.t0);
148
192
  }
193
+
149
194
  case 18:
150
195
  _context2.prev = 18;
151
196
  setLoadingIdentity(false);
152
197
  return _context2.finish(18);
198
+
153
199
  case 21:
154
200
  case "end":
155
201
  return _context2.stop();
@@ -157,6 +203,7 @@ var createAuthentication = function createAuthentication(_ref3) {
157
203
  }
158
204
  }, _callee2, null, [[2, 14, 18, 21]]);
159
205
  }));
206
+
160
207
  return function (_x3) {
161
208
  return _ref4.apply(this, arguments);
162
209
  };
@@ -168,6 +215,8 @@ var createAuthentication = function createAuthentication(_ref3) {
168
215
  onToken: onToken
169
216
  }, loadingIdentity ? /*#__PURE__*/_react.default.createElement(_LoggingIn.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));
170
217
  };
218
+
171
219
  return Authentication;
172
220
  };
221
+
173
222
  exports.createAuthentication = createAuthentication;
package/index.js.map CHANGED
@@ -1 +1 @@
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","useState","loadingIdentity","setLoadingIdentity","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, useState } 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 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\";\nimport LoggingIn from \"~/views/LoggingIn\";\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 [loadingIdentity, setLoadingIdentity] = useState(false);\n const { setIdentity } = useSecurity();\n const client = useApolloClient();\n\n const onToken = useCallback(async (token: CognitoIdToken) => {\n const { payload, logout } = token;\n\n setLoadingIdentity(true);\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 } finally {\n setLoadingIdentity(false);\n }\n }, []);\n\n useEffect(() => {\n plugins.register(createApolloLinkPlugin());\n }, []);\n\n return (\n <Authenticator onToken={onToken}>\n {loadingIdentity ? <LoggingIn /> : <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;A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EACFA,MAAM,IACL,YAAM;oBACH,OAAO,KAAK,CAAC;kBACjB;gBAAE,GACR;gBAAC;gBAAA;cAAA;gBAAA;gBAAA;gBAEHM,OAAO,CAACC,GAAG,CAAC,OAAO,eAAM;gBACzB,IAAI,OAAO7B,OAAO,KAAK,UAAU,EAAE;kBAC/BA,OAAO,cAAK;gBAChB,CAAC,MAAM;kBACH4B,OAAO,CAACE,KAAK,cAAK;gBACtB;cAAC;gBAAA;gBAEDjB,kBAAkB,CAAC,KAAK,CAAC;gBAAC;cAAA;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,CAEjC;MAAA;QAAA;MAAA;IAAA,KAAE,EAAE,CAAC;IAEN,IAAAkB,gBAAS,EAAC,YAAM;MACZC,gBAAO,CAACC,QAAQ,CAAC1D,sBAAsB,EAAE,CAAC;IAC9C,CAAC,EAAE,EAAE,CAAC;IAEN,oBACI,6BAAC,4BAAa;MAAC,OAAO,EAAE2C;IAAQ,GAC3BN,eAAe,gBAAG,6BAAC,kBAAS,OAAG,gBAAG,6BAAC,eAAM,OAAG,eAC7C,6BAAC,2BAAkB,OAAG,eACtB,6BAAC,uBAAc,OAAG,eAClB,6BAAC,uBAAc,OAAG,eAClB,6BAAC,iBAAQ,QAAEF,QAAQ,CAAY,CACnB;EAExB,CAAC;EAED,OAAOF,cAAc;AACzB,CAAC;AAAC"}
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","useState","loadingIdentity","setLoadingIdentity","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, useState } 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 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\";\nimport LoggingIn from \"~/views/LoggingIn\";\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 [loadingIdentity, setLoadingIdentity] = useState(false);\n const { setIdentity } = useSecurity();\n const client = useApolloClient();\n\n const onToken = useCallback(async (token: CognitoIdToken) => {\n const { payload, logout } = token;\n\n setLoadingIdentity(true);\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 } finally {\n setLoadingIdentity(false);\n }\n }, []);\n\n useEffect(() => {\n plugins.register(createApolloLinkPlugin());\n }, []);\n\n return (\n <Authenticator onToken={onToken}>\n {loadingIdentity ? <LoggingIn /> : <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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B,EAAmC;kBAC/BA,OAAO,cAAP;gBACH,CAFD,MAEO;kBACH4B,OAAO,CAACE,KAAR;gBACH;;cA7BmB;gBAAA;gBA+BpBjB,kBAAkB,CAAC,KAAD,CAAlB;gBA/BoB;;cAAA;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,CAAZ;;MAAA;QAAA;MAAA;IAAA,KAiCb,EAjCa,CAAhB;IAmCA,IAAAkB,gBAAA,EAAU,YAAM;MACZC,gBAAA,CAAQC,QAAR,CAAiB1D,sBAAsB,EAAvC;IACH,CAFD,EAEG,EAFH;IAIA,oBACI,6BAAC,4BAAD;MAAe,OAAO,EAAE2C;IAAxB,GACKN,eAAe,gBAAG,6BAAC,kBAAD,OAAH,gBAAmB,6BAAC,eAAD,OADvC,eAEI,6BAAC,2BAAD,OAFJ,eAGI,6BAAC,uBAAD,OAHJ,eAII,6BAAC,uBAAD,OAJJ,eAKI,6BAAC,iBAAD,QAAWF,QAAX,CALJ,CADJ;EASH,CAtDD;;EAwDA,OAAOF,cAAP;AACH,CArEM"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/app-admin-cognito",
3
- "version": "0.0.0-unstable.611c5af35e",
3
+ "version": "0.0.0-unstable.615a930a68",
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.6.14",
16
+ "@aws-amplify/auth": "4.6.8",
17
17
  "@emotion/styled": "10.3.0",
18
- "@webiny/app": "0.0.0-unstable.611c5af35e",
19
- "@webiny/app-admin": "0.0.0-unstable.611c5af35e",
20
- "@webiny/app-cognito-authenticator": "0.0.0-unstable.611c5af35e",
21
- "@webiny/app-security": "0.0.0-unstable.611c5af35e",
22
- "@webiny/form": "0.0.0-unstable.611c5af35e",
23
- "@webiny/plugins": "0.0.0-unstable.611c5af35e",
24
- "@webiny/ui": "0.0.0-unstable.611c5af35e",
25
- "@webiny/validation": "0.0.0-unstable.611c5af35e",
18
+ "@webiny/app": "0.0.0-unstable.615a930a68",
19
+ "@webiny/app-admin": "0.0.0-unstable.615a930a68",
20
+ "@webiny/app-cognito-authenticator": "0.0.0-unstable.615a930a68",
21
+ "@webiny/app-security": "0.0.0-unstable.615a930a68",
22
+ "@webiny/form": "0.0.0-unstable.615a930a68",
23
+ "@webiny/plugins": "0.0.0-unstable.615a930a68",
24
+ "@webiny/ui": "0.0.0-unstable.615a930a68",
25
+ "@webiny/validation": "0.0.0-unstable.615a930a68",
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.19.4",
38
38
  "@babel/preset-react": "^7.16.0",
39
39
  "@babel/preset-typescript": "^7.18.6",
40
- "@webiny/cli": "^0.0.0-unstable.611c5af35e",
41
- "@webiny/project-utils": "^0.0.0-unstable.611c5af35e",
40
+ "@webiny/cli": "^0.0.0-unstable.615a930a68",
41
+ "@webiny/project-utils": "^0.0.0-unstable.615a930a68",
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": "cdeed09317c2c0e07cb0d4d88f9ac38a214ddc22"
62
+ "gitHead": "615a930a68d692c832e4f100405eeb3f5a8874af"
63
63
  }
@@ -1,42 +1,63 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
4
5
  var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
6
+
5
7
  Object.defineProperty(exports, "__esModule", {
6
8
  value: true
7
9
  });
8
10
  exports.default = void 0;
11
+
9
12
  var React = _interopRequireWildcard(require("react"));
13
+
10
14
  var _form = require("@webiny/form");
15
+
11
16
  var _validation = require("@webiny/validation");
17
+
12
18
  var _Button = require("@webiny/ui/Button");
19
+
13
20
  var _Input = require("@webiny/ui/Input");
21
+
14
22
  var _Grid = require("@webiny/ui/Grid");
23
+
15
24
  var _Typography = require("@webiny/ui/Typography");
25
+
16
26
  var _Alert = require("@webiny/ui/Alert");
27
+
17
28
  var _Elevation = require("@webiny/ui/Elevation");
29
+
18
30
  var _StateContainer = _interopRequireDefault(require("./StateContainer"));
31
+
19
32
  var _StyledComponents = require("./StyledComponents");
33
+
20
34
  var _Progress = require("@webiny/ui/Progress");
35
+
21
36
  var _useAuthenticator2 = require("@webiny/app-cognito-authenticator/hooks/useAuthenticator");
37
+
22
38
  var _useForgotPassword2 = require("@webiny/app-cognito-authenticator/hooks/useForgotPassword");
39
+
23
40
  var ForgotPassword = function ForgotPassword() {
24
41
  var _useAuthenticator = (0, _useAuthenticator2.useAuthenticator)(),
25
- authData = _useAuthenticator.authData,
26
- changeState = _useAuthenticator.changeState;
42
+ authData = _useAuthenticator.authData,
43
+ changeState = _useAuthenticator.changeState;
44
+
27
45
  var _useForgotPassword = (0, _useForgotPassword2.useForgotPassword)(),
28
- loading = _useForgotPassword.loading,
29
- codeSent = _useForgotPassword.codeSent,
30
- shouldRender = _useForgotPassword.shouldRender,
31
- setPassword = _useForgotPassword.setPassword,
32
- requestCode = _useForgotPassword.requestCode,
33
- error = _useForgotPassword.error;
46
+ loading = _useForgotPassword.loading,
47
+ codeSent = _useForgotPassword.codeSent,
48
+ shouldRender = _useForgotPassword.shouldRender,
49
+ setPassword = _useForgotPassword.setPassword,
50
+ requestCode = _useForgotPassword.requestCode,
51
+ error = _useForgotPassword.error;
52
+
34
53
  if (!shouldRender) {
35
54
  return null;
36
55
  }
56
+
37
57
  var _ref = authData || {},
38
- _ref$username = _ref.username,
39
- username = _ref$username === void 0 ? "" : _ref$username;
58
+ _ref$username = _ref.username,
59
+ username = _ref$username === void 0 ? "" : _ref$username;
60
+
40
61
  return /*#__PURE__*/React.createElement(_StateContainer.default, null, /*#__PURE__*/React.createElement(_form.Form, {
41
62
  data: {
42
63
  username: username
@@ -52,8 +73,8 @@ var ForgotPassword = function ForgotPassword() {
52
73
  submitOnEnter: true
53
74
  }, function (_ref3) {
54
75
  var Bind = _ref3.Bind,
55
- submit = _ref3.submit,
56
- data = _ref3.data;
76
+ submit = _ref3.submit,
77
+ data = _ref3.data;
57
78
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Elevation.Elevation, {
58
79
  z: 2
59
80
  }, /*#__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, {
@@ -114,5 +135,6 @@ var ForgotPassword = function ForgotPassword() {
114
135
  }, "Sign in"))));
115
136
  }));
116
137
  };
138
+
117
139
  var _default = ForgotPassword;
118
140
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"names":["ForgotPassword","useAuthenticator","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 { authData, changeState } = useAuthenticator();\n const { loading, codeSent, shouldRender, setPassword, requestCode, error } =\n useForgotPassword();\n\n if (!shouldRender) {\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=\"body2\">\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 data-testid=\"send-code\"\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,cAAwB,GAAS;EACnC,wBAAkC,IAAAC,mCAAgB,GAAE;IAA5CC,QAAQ,qBAARA,QAAQ;IAAEC,WAAW,qBAAXA,WAAW;EAC7B,yBACI,IAAAC,qCAAiB,GAAE;IADfC,OAAO,sBAAPA,OAAO;IAAEC,QAAQ,sBAARA,QAAQ;IAAEC,YAAY,sBAAZA,YAAY;IAAEC,WAAW,sBAAXA,WAAW;IAAEC,WAAW,sBAAXA,WAAW;IAAEC,KAAK,sBAALA,KAAK;EAGxE,IAAI,CAACH,YAAY,EAAE;IACf,OAAO,IAAI;EACf;EAEA,WAA0BL,QAAQ,IAAI,CAAC,CAAC;IAAA,qBAAhCS,QAAQ;IAARA,QAAQ,8BAAG,EAAE;EAErB,oBACI,oBAAC,uBAAc,qBACX,oBAAC,UAAI;IACD,IAAI,EAAE;MAAEA,QAAQ,EAARA;IAAS,CAAE;IACnB,QAAQ,EAAE;MAAA,IAAGA,QAAQ,SAARA,QAAQ;MAAA,OACjBL,QAAQ,GAAGE,WAAW,CAAC;QAAEG,QAAQ,EAARA;MAAS,CAAC,CAAC,GAAGF,WAAW,CAAC;QAAEE,QAAQ,EAARA;MAAS,CAAC,CAAC;IAAA,CACnE;IACD,aAAa;EAAA,GAEZ;IAAA,IAAGC,IAAI,SAAJA,IAAI;MAAEC,MAAM,SAANA,MAAM;MAAEC,I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AM,8GAIG,CACV,CACJ,eACP,oBAAC,UAAI,qBACD,oBAAC,UAAI;MAAC,IAAI,EAAE,EAAG;MAAC,SAAS,EAAED;IAAW,gBAClC,oBAAC,qBAAa;MACV,OAAO,EAAE,mBAAM;QACXX,WAAW,CAAC;UAAEE,QAAQ,EAAEG,IAAI,CAACH;QAAS,CAAC,CAAC;MAC5C;IAAE,GAED,aAAa,CACF,eAChB,oBAAC,qBAAa;MACV,OAAO,EAAE,iBAAAU,EAAE,EAAI;QACXR,MAAM,CAACQ,EAAE,CAAC;MACd;IAAE,qBAGU,CACb,CACJ,CAEd,CACU,CACP,eACZ,oBAAC,UAAI,qBACD,oBAAC,UAAI;MAAC,IAAI,EAAE,EAAG;MAAC,KAAK,EAAE;QAAEC,SAAS,EAAE;MAAS;IAAE,qCAE3C;MAAG,IAAI,EAAE,GAAI;MAAC,OAAO,EAAE;QAAA,OAAMnB,WAAW,CAAC,QAAQ,CAAC;MAAA;IAAC,aAE/C,CACD,CACJ,CACR;EAAA,CACN,CACE,CACM;AAEzB,CAAC;AAAC,eAEaH,cAAc;AAAA"}
1
+ {"version":3,"names":["ForgotPassword","useAuthenticator","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 { authData, changeState } = useAuthenticator();\n const { loading, codeSent, shouldRender, setPassword, requestCode, error } =\n useForgotPassword();\n\n if (!shouldRender) {\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=\"body2\">\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 data-testid=\"send-code\"\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,wBAAkC,IAAAC,mCAAA,GAAlC;EAAA,IAAQC,QAAR,qBAAQA,QAAR;EAAA,IAAkBC,WAAlB,qBAAkBA,WAAlB;;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,YAAL,EAAmB;IACf,OAAO,IAAP;EACH;;EAED,WAA0BL,QAAQ,IAAI,EAAtC;EAAA,yBAAQS,QAAR;EAAA,IAAQA,QAAR,8BAAmB,EAAnB;;EAEA,oBACI,oBAAC,uBAAD,qBACI,oBAAC,UAAD;IACI,IAAI,EAAE;MAAEA,QAAQ,EAARA;IAAF,CADV;IAEI,QAAQ,EAAE;MAAA,IAAGA,QAAH,SAAGA,QAAH;MAAA,OACNL,QAAQ,GAAGE,WAAW,CAAC;QAAEG,QAAQ,EAARA;MAAF,CAAD,CAAd,GAA+BF,WAAW,CAAC;QAAEE,QAAQ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ADJ,CADJ,CArBJ,CADH,gBAoCG,uDACI,oBAAC,UAAD,qBACI,oBAAC,UAAD;MAAM,IAAI,EAAE;IAAZ,gBACI,oBAAC,sBAAD;MAAY,GAAG,EAAC;IAAhB,mEAEI,+BAFJ,eAGI,+BAHJ,8GADJ,CADJ,CADJ,eAaI,oBAAC,UAAD,qBACI,oBAAC,UAAD;MAAM,IAAI,EAAE,EAAZ;MAAgB,SAAS,EAAED;IAA3B,gBACI,oBAAC,qBAAD;MACI,OAAO,EAAE,mBAAM;QACXX,WAAW,CAAC;UAAEE,QAAQ,EAAEG,IAAI,CAACH;QAAjB,CAAD,CAAX;MACH;IAHL,GAKK,aALL,CADJ,eAQI,oBAAC,qBAAD;MACI,OAAO,EAAE,iBAAAU,EAAE,EAAI;QACXR,MAAM,CAACQ,EAAD,CAAN;MACH;IAHL,qBARJ,CADJ,CAbJ,CA3DR,CADJ,CADJ,eAgGI,oBAAC,UAAD,qBACI,oBAAC,UAAD;MAAM,IAAI,EAAE,EAAZ;MAAgB,KAAK,EAAE;QAAEC,SAAS,EAAE;MAAb;IAAvB,qCAEI;MAAG,IAAI,EAAE,GAAT;MAAc,OAAO,EAAE;QAAA,OAAMnB,WAAW,CAAC,QAAD,CAAjB;MAAA;IAAvB,aAFJ,CADJ,CAhGJ,CADH;EAAA,CAPL,CADJ,CADJ;AAuHH,CAlID;;eAoIeH,c"}
@@ -1,16 +1,21 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = void 0;
9
+
8
10
  var _react = _interopRequireDefault(require("react"));
11
+
9
12
  var _Progress = require("@webiny/ui/Progress");
13
+
10
14
  var LoggingIn = function LoggingIn() {
11
15
  return /*#__PURE__*/_react.default.createElement(_Progress.CircularProgress, {
12
16
  label: "Loading identity..."
13
17
  });
14
18
  };
19
+
15
20
  var _default = LoggingIn;
16
21
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"names":["LoggingIn"],"sources":["LoggingIn.tsx"],"sourcesContent":["import React from \"react\";\nimport { CircularProgress } from \"@webiny/ui/Progress\";\n\nconst LoggingIn: React.FC = () => {\n return <CircularProgress label={\"Loading identity...\"} />;\n};\n\nexport default LoggingIn;\n"],"mappings":";;;;;;;AAAA;AACA;AAEA,IAAMA,SAAmB,GAAG,SAAtBA,SAAmB,GAAS;EAC9B,oBAAO,6BAAC,0BAAgB;IAAC,KAAK,EAAE;EAAsB,EAAG;AAC7D,CAAC;AAAC,eAEaA,SAAS;AAAA"}
1
+ {"version":3,"names":["LoggingIn"],"sources":["LoggingIn.tsx"],"sourcesContent":["import React from \"react\";\nimport { CircularProgress } from \"@webiny/ui/Progress\";\n\nconst LoggingIn: React.FC = () => {\n return <CircularProgress label={\"Loading identity...\"} />;\n};\n\nexport default LoggingIn;\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEA,IAAMA,SAAmB,GAAG,SAAtBA,SAAsB,GAAM;EAC9B,oBAAO,6BAAC,0BAAD;IAAkB,KAAK,EAAE;EAAzB,EAAP;AACH,CAFD;;eAIeA,S"}
@@ -1,37 +1,53 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = void 0;
9
+
8
10
  var _react = _interopRequireDefault(require("react"));
11
+
9
12
  var _form = require("@webiny/form");
13
+
10
14
  var _validation = require("@webiny/validation");
15
+
11
16
  var _Button = require("@webiny/ui/Button");
17
+
12
18
  var _Input = require("@webiny/ui/Input");
19
+
13
20
  var _Grid = require("@webiny/ui/Grid");
21
+
14
22
  var _Typography = require("@webiny/ui/Typography");
23
+
15
24
  var _Elevation = require("@webiny/ui/Elevation");
25
+
16
26
  var _useRequireNewPassword = require("@webiny/app-cognito-authenticator/hooks/useRequireNewPassword");
27
+
17
28
  var _StateContainer = _interopRequireDefault(require("./StateContainer"));
29
+
18
30
  var _StyledComponents = require("./StyledComponents");
31
+
19
32
  var sentenceCase = function sentenceCase(str) {
20
33
  var lower = str.toLowerCase();
21
34
  return lower[0].toUpperCase() + lower.substring(1);
22
35
  };
36
+
23
37
  var RequireNewPassword = function RequireNewPassword() {
24
38
  var _useRequireNewPasswor = (0, _useRequireNewPassword.useRequireNewPassword)(),
25
- shouldRender = _useRequireNewPasswor.shouldRender,
26
- requiredAttributes = _useRequireNewPasswor.requiredAttributes,
27
- confirm = _useRequireNewPasswor.confirm;
39
+ shouldRender = _useRequireNewPasswor.shouldRender,
40
+ requiredAttributes = _useRequireNewPasswor.requiredAttributes,
41
+ confirm = _useRequireNewPasswor.confirm;
42
+
28
43
  if (!shouldRender) {
29
44
  return null;
30
45
  }
46
+
31
47
  return /*#__PURE__*/_react.default.createElement(_StateContainer.default, null, /*#__PURE__*/_react.default.createElement(_form.Form, {
32
48
  onSubmit: function onSubmit(_ref) {
33
49
  var password = _ref.password,
34
- requiredAttributes = _ref.requiredAttributes;
50
+ requiredAttributes = _ref.requiredAttributes;
35
51
  return confirm({
36
52
  password: password,
37
53
  requiredAttributes: requiredAttributes
@@ -40,7 +56,7 @@ var RequireNewPassword = function RequireNewPassword() {
40
56
  submitOnEnter: true
41
57
  }, function (_ref2) {
42
58
  var Bind = _ref2.Bind,
43
- submit = _ref2.submit;
59
+ submit = _ref2.submit;
44
60
  return /*#__PURE__*/_react.default.createElement(_Elevation.Elevation, {
45
61
  z: 2
46
62
  }, /*#__PURE__*/_react.default.createElement(_StyledComponents.InnerContent, null, /*#__PURE__*/_react.default.createElement(_StyledComponents.Title, null, /*#__PURE__*/_react.default.createElement(_Typography.Typography, {
@@ -78,5 +94,6 @@ var RequireNewPassword = function RequireNewPassword() {
78
94
  }, "Set password")))));
79
95
  }));
80
96
  };
97
+
81
98
  var _default = RequireNewPassword;
82
99
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"names":["sentenceCase","str","lower","toLowerCase","toUpperCase","substring","RequireNewPassword","useRequireNewPassword","shouldRender","requiredAttributes","confirm","password","Bind","submit","validation","create","length","map","name","alignRight","ev"],"sources":["RequireNewPassword.tsx"],"sourcesContent":["import React from \"react\";\nimport { Form } from \"@webiny/form\";\nimport { validation } from \"@webiny/validation\";\nimport { ButtonPrimary } from \"@webiny/ui/Button\";\nimport { Input } from \"@webiny/ui/Input\";\nimport { Grid, Cell } from \"@webiny/ui/Grid\";\nimport { Typography } from \"@webiny/ui/Typography\";\nimport { Elevation } from \"@webiny/ui/Elevation\";\nimport { useRequireNewPassword } from \"@webiny/app-cognito-authenticator/hooks/useRequireNewPassword\";\nimport StateContainer from \"./StateContainer\";\nimport { alignRight, InnerContent, Title } from \"./StyledComponents\";\n\nconst sentenceCase = (str: string) => {\n const lower = str.toLowerCase();\n return lower[0].toUpperCase() + lower.substring(1);\n};\n\nconst RequireNewPassword: React.FC = () => {\n const { shouldRender, requiredAttributes, confirm } = useRequireNewPassword();\n\n if (!shouldRender) {\n return null;\n }\n\n return (\n <StateContainer>\n <Form\n onSubmit={({ password, requiredAttributes }) =>\n confirm({ password, requiredAttributes })\n }\n submitOnEnter\n >\n {({ Bind, submit }) => (\n <Elevation z={2}>\n <InnerContent>\n <Title>\n <Typography use=\"headline4\">Set New Password</Typography>\n </Title>\n\n <Grid>\n <Cell span={12}>\n <Bind\n name=\"password\"\n validators={validation.create(\"required\")}\n >\n <Input\n type={\"password\"}\n label={\"New password\"}\n outlined={true}\n />\n </Bind>\n </Cell>\n </Grid>\n {requiredAttributes.length > 0 && (\n <Title>\n <Typography use=\"headline6\">\n Please enter additional information\n </Typography>\n </Title>\n )}\n <Grid>\n {requiredAttributes.map(name => (\n <Cell key={name} span={12}>\n <Bind\n name={name}\n validators={validation.create(\"required\")}\n >\n <Input label={sentenceCase(name)} outlined={true} />\n </Bind>\n </Cell>\n ))}\n </Grid>\n\n <Grid>\n <Cell span={12} className={alignRight}>\n <ButtonPrimary\n data-testid=\"submit-sign-in-form-button\"\n onClick={ev => {\n submit(ev);\n }}\n >\n {\"Set password\"}\n </ButtonPrimary>\n </Cell>\n </Grid>\n </InnerContent>\n </Elevation>\n )}\n </Form>\n </StateContainer>\n );\n};\n\nexport default RequireNewPassword;\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,IAAMA,YAAY,GAAG,SAAfA,YAAY,CAAIC,GAAW,EAAK;EAClC,IAAMC,KAAK,GAAGD,GAAG,CAACE,WAAW,EAAE;EAC/B,OAAOD,KAAK,CAAC,CAAC,CAAC,CAACE,WAAW,EAAE,GAAGF,KAAK,CAACG,SAAS,CAAC,CAAC,CAAC;AACtD,CAAC;AAED,IAAMC,kBAA4B,GAAG,SAA/BA,kBAA4B,GAAS;EACvC,4BAAsD,IAAAC,4CAAqB,GAAE;IAArEC,YAAY,yBAAZA,YAAY;IAAEC,kBAAkB,yBAAlBA,kBAAkB;IAAEC,OAAO,yBAAPA,OAAO;EAEjD,IAAI,CAACF,YAAY,EAAE;IACf,OAAO,IAAI;EACf;EAEA,oBACI,6BAAC,uBAAc,qBACX,6BAAC,UAAI;IACD,QAAQ,EAAE;MAAA,IAAGG,QAAQ,QAARA,QAAQ;QAAEF,kBAAkB,QAAlBA,kBAAkB;MAAA,OACrCC,OAAO,CAAC;QAAEC,QAAQ,EAARA,QAAQ;QAAEF,kBAAkB,EAAlBA;MAAmB,CAAC,CAAC;IAAA,CAC5C;IACD,aAAa;EAAA,GAEZ;IAAA,IAAGG,IAAI,SAAJA,IAAI;MAAEC,MAAM,SAANA,MAAM;IAAA,oBACZ,6BAAC,oBAAS;MAAC,CAAC,EAAE;IAAE,gBACZ,6BAAC,8BAAY,qBACT,6BAAC,uBAAK,qBACF,6BAAC,sBAAU;MAAC,GAAG,EAAC;IAAW,sBAA8B,CACrD,eAER,6BAAC,UAAI,qBACD,6BAAC,UAAI;MAAC,IAAI,EAAE;IAAG,gBACX,6BAAC,IAAI;MACD,IAAI,EAAC,UAAU;MACf,UAAU,EAAEC,sBAAU,CAACC,MAAM,CAAC,UAAU;IAAE,gBAE1C,6BAAC,YAAK;MACF,IAAI,EAAE,UAAW;MACjB,KAAK,EAAE,cAAe;MACtB,QAAQ,EAAE;IAAK,EACjB,CACC,CACJ,CACJ,EACNN,kBAAkB,CAACO,MAAM,GAAG,CAAC,iBAC1B,6BAAC,uBAAK,qBACF,6BAAC,sBAAU;MAAC,GAAG,EAAC;IAAW,yCAEd,CAEpB,eACD,6BAAC,UAAI,QACAP,kBAAkB,CAACQ,GAAG,CAAC,UAAAC,IAAI;MAAA,oBACxB,6BAAC,UAAI;QAAC,GAAG,EAAEA,IAAK;QAAC,IAAI,EAAE;MAAG,gBACtB,6BAAC,IAAI;QACD,IAAI,EAAEA,IAAK;QACX,UAAU,EAAEJ,sBAAU,CAACC,MAAM,CAAC,UAAU;MAAE,gBAE1C,6BAAC,YAAK;QAAC,KAAK,EAAEf,YAAY,CAACkB,IAAI,CAAE;QAAC,QAAQ,EAAE;MAAK,EAAG,CACjD,CACJ;IAAA,CACV,CAAC,CACC,eAEP,6BAAC,UAAI,qBACD,6BAAC,UAAI;MAAC,IAAI,EAAE,EAAG;MAAC,SAAS,EAAEC;IAAW,gBAClC,6BAAC,qBAAa;MACV,eAAY,4BAA4B;MACxC,OAAO,EAAE,iBAAAC,EAAE,EAAI;QACXP,MAAM,CAACO,EAAE,CAAC;MACd;IAAE,GAED,cAAc,CACH,CACb,CACJ,CACI,CACP;EAAA,CACf,CACE,CACM;AAEzB,CAAC;AAAC,eAEad,kBAAkB;AAAA"}
1
+ {"version":3,"names":["sentenceCase","str","lower","toLowerCase","toUpperCase","substring","RequireNewPassword","useRequireNewPassword","shouldRender","requiredAttributes","confirm","password","Bind","submit","validation","create","length","map","name","alignRight","ev"],"sources":["RequireNewPassword.tsx"],"sourcesContent":["import React from \"react\";\nimport { Form } from \"@webiny/form\";\nimport { validation } from \"@webiny/validation\";\nimport { ButtonPrimary } from \"@webiny/ui/Button\";\nimport { Input } from \"@webiny/ui/Input\";\nimport { Grid, Cell } from \"@webiny/ui/Grid\";\nimport { Typography } from \"@webiny/ui/Typography\";\nimport { Elevation } from \"@webiny/ui/Elevation\";\nimport { useRequireNewPassword } from \"@webiny/app-cognito-authenticator/hooks/useRequireNewPassword\";\nimport StateContainer from \"./StateContainer\";\nimport { alignRight, InnerContent, Title } from \"./StyledComponents\";\n\nconst sentenceCase = (str: string) => {\n const lower = str.toLowerCase();\n return lower[0].toUpperCase() + lower.substring(1);\n};\n\nconst RequireNewPassword: React.FC = () => {\n const { shouldRender, requiredAttributes, confirm } = useRequireNewPassword();\n\n if (!shouldRender) {\n return null;\n }\n\n return (\n <StateContainer>\n <Form\n onSubmit={({ password, requiredAttributes }) =>\n confirm({ password, requiredAttributes })\n }\n submitOnEnter\n >\n {({ Bind, submit }) => (\n <Elevation z={2}>\n <InnerContent>\n <Title>\n <Typography use=\"headline4\">Set New Password</Typography>\n </Title>\n\n <Grid>\n <Cell span={12}>\n <Bind\n name=\"password\"\n validators={validation.create(\"required\")}\n >\n <Input\n type={\"password\"}\n label={\"New password\"}\n outlined={true}\n />\n </Bind>\n </Cell>\n </Grid>\n {requiredAttributes.length > 0 && (\n <Title>\n <Typography use=\"headline6\">\n Please enter additional information\n </Typography>\n </Title>\n )}\n <Grid>\n {requiredAttributes.map(name => (\n <Cell key={name} span={12}>\n <Bind\n name={name}\n validators={validation.create(\"required\")}\n >\n <Input label={sentenceCase(name)} outlined={true} />\n </Bind>\n </Cell>\n ))}\n </Grid>\n\n <Grid>\n <Cell span={12} className={alignRight}>\n <ButtonPrimary\n data-testid=\"submit-sign-in-form-button\"\n onClick={ev => {\n submit(ev);\n }}\n >\n {\"Set password\"}\n </ButtonPrimary>\n </Cell>\n </Grid>\n </InnerContent>\n </Elevation>\n )}\n </Form>\n </StateContainer>\n );\n};\n\nexport default RequireNewPassword;\n"],"mappings":";;;;;;;;;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AE,cAFX;MAGI,QAAQ,EAAE;IAHd,EAJJ,CADJ,CADJ,CALJ,EAmBKN,kBAAkB,CAACO,MAAnB,GAA4B,CAA5B,iBACG,6BAAC,uBAAD,qBACI,6BAAC,sBAAD;MAAY,GAAG,EAAC;IAAhB,yCADJ,CApBR,eA0BI,6BAAC,UAAD,QACKP,kBAAkB,CAACQ,GAAnB,CAAuB,UAAAC,IAAI;MAAA,oBACxB,6BAAC,UAAD;QAAM,GAAG,EAAEA,IAAX;QAAiB,IAAI,EAAE;MAAvB,gBACI,6BAAC,IAAD;QACI,IAAI,EAAEA,IADV;QAEI,UAAU,EAAEJ,sBAAA,CAAWC,MAAX,CAAkB,UAAlB;MAFhB,gBAII,6BAAC,YAAD;QAAO,KAAK,EAAEf,YAAY,CAACkB,IAAD,CAA1B;QAAkC,QAAQ,EAAE;MAA5C,EAJJ,CADJ,CADwB;IAAA,CAA3B,CADL,CA1BJ,eAuCI,6BAAC,UAAD,qBACI,6BAAC,UAAD;MAAM,IAAI,EAAE,EAAZ;MAAgB,SAAS,EAAEC;IAA3B,gBACI,6BAAC,qBAAD;MACI,eAAY,4BADhB;MAEI,OAAO,EAAE,iBAAAC,EAAE,EAAI;QACXP,MAAM,CAACO,EAAD,CAAN;MACH;IAJL,GAMK,cANL,CADJ,CADJ,CAvCJ,CADJ,CADH;EAAA,CANL,CADJ,CADJ;AAmEH,CA1ED;;eA4Eed,kB"}
@@ -1,34 +1,52 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = void 0;
9
+
8
10
  var _react = _interopRequireDefault(require("react"));
11
+
9
12
  var _form = require("@webiny/form");
13
+
10
14
  var _validation = require("@webiny/validation");
15
+
11
16
  var _Button = require("@webiny/ui/Button");
17
+
12
18
  var _Input = require("@webiny/ui/Input");
19
+
13
20
  var _Grid = require("@webiny/ui/Grid");
21
+
14
22
  var _Typography = require("@webiny/ui/Typography");
23
+
15
24
  var _Elevation = require("@webiny/ui/Elevation");
25
+
16
26
  var _Progress = require("@webiny/ui/Progress");
27
+
17
28
  var _StateContainer = _interopRequireDefault(require("./StateContainer"));
29
+
18
30
  var _StyledComponents = require("./StyledComponents");
31
+
19
32
  var _useAuthenticator2 = require("@webiny/app-cognito-authenticator/hooks/useAuthenticator");
33
+
20
34
  var _useSetNewPassword2 = require("@webiny/app-cognito-authenticator/hooks/useSetNewPassword");
35
+
21
36
  var SetNewPassword = function SetNewPassword() {
22
37
  var _useAuthenticator = (0, _useAuthenticator2.useAuthenticator)(),
23
- changeState = _useAuthenticator.changeState;
38
+ changeState = _useAuthenticator.changeState;
39
+
24
40
  var _useSetNewPassword = (0, _useSetNewPassword2.useSetNewPassword)(),
25
- shouldRender = _useSetNewPassword.shouldRender,
26
- setPassword = _useSetNewPassword.setPassword,
27
- error = _useSetNewPassword.error,
28
- loading = _useSetNewPassword.loading;
41
+ shouldRender = _useSetNewPassword.shouldRender,
42
+ setPassword = _useSetNewPassword.setPassword,
43
+ error = _useSetNewPassword.error,
44
+ loading = _useSetNewPassword.loading;
45
+
29
46
  if (!shouldRender) {
30
47
  return null;
31
48
  }
49
+
32
50
  return /*#__PURE__*/_react.default.createElement(_StateContainer.default, null, /*#__PURE__*/_react.default.createElement(_form.Form, {
33
51
  onSubmit: function onSubmit(data) {
34
52
  /**
@@ -39,13 +57,15 @@ var SetNewPassword = function SetNewPassword() {
39
57
  submitOnEnter: true
40
58
  }, function (_ref) {
41
59
  var Bind = _ref.Bind,
42
- submit = _ref.submit,
43
- data = _ref.data;
60
+ submit = _ref.submit,
61
+ data = _ref.data;
62
+
44
63
  var retypePasswordValidator = function retypePasswordValidator(value) {
45
64
  if (value !== data.password) {
46
65
  throw Error("Passwords do not match!");
47
66
  }
48
67
  };
68
+
49
69
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Elevation.Elevation, {
50
70
  z: 2
51
71
  }, /*#__PURE__*/_react.default.createElement(_StyledComponents.InnerContent, null, loading && /*#__PURE__*/_react.default.createElement(_Progress.CircularProgress, null), /*#__PURE__*/_react.default.createElement(_StyledComponents.Title, null, /*#__PURE__*/_react.default.createElement("h1", null, /*#__PURE__*/_react.default.createElement(_Typography.Typography, {
@@ -108,5 +128,6 @@ var SetNewPassword = function SetNewPassword() {
108
128
  }, "Sign in"))));
109
129
  }));
110
130
  };
131
+
111
132
  var _default = SetNewPassword;
112
133
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"names":["SetNewPassword","useAuthenticator","changeState","useSetNewPassword","shouldRender","setPassword","error","loading","data","Bind","submit","retypePasswordValidator","value","password","Error","errorMessage","validation","create","alignRight","ev","textAlign"],"sources":["SetNewPassword.tsx"],"sourcesContent":["import React from \"react\";\nimport { Form } from \"@webiny/form\";\nimport { validation } from \"@webiny/validation\";\nimport { ButtonPrimary } from \"@webiny/ui/Button\";\nimport { Input } from \"@webiny/ui/Input\";\nimport { Grid, Cell } from \"@webiny/ui/Grid\";\nimport { Typography } from \"@webiny/ui/Typography\";\nimport { Elevation } from \"@webiny/ui/Elevation\";\nimport { CircularProgress } from \"@webiny/ui/Progress\";\nimport StateContainer from \"./StateContainer\";\nimport { alignRight, InnerContent, Title, errorMessage } from \"./StyledComponents\";\nimport { useAuthenticator } from \"@webiny/app-cognito-authenticator/hooks/useAuthenticator\";\nimport {\n useSetNewPassword,\n UseSetNewPasswordCallableParams\n} from \"@webiny/app-cognito-authenticator/hooks/useSetNewPassword\";\n\nconst SetNewPassword: React.FC = () => {\n const { changeState } = useAuthenticator();\n const { shouldRender, setPassword, error, loading } = useSetNewPassword();\n\n if (!shouldRender) {\n return null;\n }\n\n return (\n <StateContainer>\n <Form\n onSubmit={data => {\n /**\n * We are positive that data is UseSetNewPasswordCallableParams\n */\n return setPassword(data as unknown as UseSetNewPasswordCallableParams);\n }}\n submitOnEnter\n >\n {({ Bind, submit, data }) => {\n const retypePasswordValidator = (value: string) => {\n if (value !== data.password) {\n throw Error(\"Passwords do not match!\");\n }\n };\n\n return (\n <>\n <Elevation z={2}>\n <InnerContent>\n {loading && <CircularProgress />}\n <Title>\n <h1>\n <Typography use=\"headline4\">\n Set New Password\n </Typography>\n </h1>\n </Title>\n\n {error && (\n <Grid>\n <Cell span={12} className={errorMessage}>\n {error}\n </Cell>\n </Grid>\n )}\n\n <Grid>\n <Cell span={12} data-testid=\"password-reset-code\">\n <Bind\n name=\"code\"\n validators={validation.create(\"required\")}\n >\n <Input\n autoComplete=\"off\"\n label={\"Password reset code\"}\n outlined={true}\n description={\n \"Enter the code we sent to your email.\"\n }\n />\n </Bind>\n </Cell>\n <Cell span={12} data-testid=\"new-password-input\">\n <Bind\n name=\"password\"\n validators={validation.create(\"required\")}\n >\n <Input\n autoComplete={\"off\"}\n type={\"password\"}\n label={\"New password\"}\n outlined={true}\n description={\"Enter your new password.\"}\n />\n </Bind>\n </Cell>\n <Cell span={12} data-testid=\"retype-password-input\">\n <Bind\n name=\"retypePassword\"\n validators={[\n validation.create(\"required\"),\n retypePasswordValidator\n ]}\n >\n <Input\n type={\"password\"}\n label={\"Retype password\"}\n outlined={true}\n description={\n \"Enter your new password once more.\"\n }\n />\n </Bind>\n </Cell>\n <Cell span={12} className={alignRight}>\n <ButtonPrimary\n data-testid=\"submit-btn-new-psw\"\n onClick={ev => {\n submit(ev);\n }}\n >\n {\"Set new password\"}\n </ButtonPrimary>\n </Cell>\n </Grid>\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 }}\n </Form>\n </StateContainer>\n );\n};\n\nexport default SetNewPassword;\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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CAAC,QAAQ,CAAC;MAAA;IAAC,aAE/C,CACD,CACJ,CACR;EAEX,CAAC,CACE,CACM;AAEzB,CAAC;AAAC,eAEaF,cAAc;AAAA"}
1
+ {"version":3,"names":["SetNewPassword","useAuthenticator","changeState","useSetNewPassword","shouldRender","setPassword","error","loading","data","Bind","submit","retypePasswordValidator","value","password","Error","errorMessage","validation","create","alignRight","ev","textAlign"],"sources":["SetNewPassword.tsx"],"sourcesContent":["import React from \"react\";\nimport { Form } from \"@webiny/form\";\nimport { validation } from \"@webiny/validation\";\nimport { ButtonPrimary } from \"@webiny/ui/Button\";\nimport { Input } from \"@webiny/ui/Input\";\nimport { Grid, Cell } from \"@webiny/ui/Grid\";\nimport { Typography } from \"@webiny/ui/Typography\";\nimport { Elevation } from \"@webiny/ui/Elevation\";\nimport { CircularProgress } from \"@webiny/ui/Progress\";\nimport StateContainer from \"./StateContainer\";\nimport { alignRight, InnerContent, Title, errorMessage } from \"./StyledComponents\";\nimport { useAuthenticator } from \"@webiny/app-cognito-authenticator/hooks/useAuthenticator\";\nimport {\n useSetNewPassword,\n UseSetNewPasswordCallableParams\n} from \"@webiny/app-cognito-authenticator/hooks/useSetNewPassword\";\n\nconst SetNewPassword: React.FC = () => {\n const { changeState } = useAuthenticator();\n const { shouldRender, setPassword, error, loading } = useSetNewPassword();\n\n if (!shouldRender) {\n return null;\n }\n\n return (\n <StateContainer>\n <Form\n onSubmit={data => {\n /**\n * We are positive that data is UseSetNewPasswordCallableParams\n */\n return setPassword(data as unknown as UseSetNewPasswordCallableParams);\n }}\n submitOnEnter\n >\n {({ Bind, submit, data }) => {\n const retypePasswordValidator = (value: string) => {\n if (value !== data.password) {\n throw Error(\"Passwords do not match!\");\n }\n };\n\n return (\n <>\n <Elevation z={2}>\n <InnerContent>\n {loading && <CircularProgress />}\n <Title>\n <h1>\n <Typography use=\"headline4\">\n Set New Password\n </Typography>\n </h1>\n </Title>\n\n {error && (\n <Grid>\n <Cell span={12} className={errorMessage}>\n {error}\n </Cell>\n </Grid>\n )}\n\n <Grid>\n <Cell span={12} data-testid=\"password-reset-code\">\n <Bind\n name=\"code\"\n validators={validation.create(\"required\")}\n >\n <Input\n autoComplete=\"off\"\n label={\"Password reset code\"}\n outlined={true}\n description={\n \"Enter the code we sent to your email.\"\n }\n />\n </Bind>\n </Cell>\n <Cell span={12} data-testid=\"new-password-input\">\n <Bind\n name=\"password\"\n validators={validation.create(\"required\")}\n >\n <Input\n autoComplete={\"off\"}\n type={\"password\"}\n label={\"New password\"}\n outlined={true}\n description={\"Enter your new password.\"}\n />\n </Bind>\n </Cell>\n <Cell span={12} data-testid=\"retype-password-input\">\n <Bind\n name=\"retypePassword\"\n validators={[\n validation.create(\"required\"),\n retypePasswordValidator\n ]}\n >\n <Input\n type={\"password\"}\n label={\"Retype password\"}\n outlined={true}\n description={\n \"Enter your new password once more.\"\n }\n />\n </Bind>\n </Cell>\n <Cell span={12} className={alignRight}>\n <ButtonPrimary\n data-testid=\"submit-btn-new-psw\"\n onClick={ev => {\n submit(ev);\n }}\n >\n {\"Set new password\"}\n </ButtonPrimary>\n </Cell>\n </Grid>\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 }}\n </Form>\n </StateContainer>\n );\n};\n\nexport default SetNewPassword;\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA,IAAMA,cAAwB,GAAG,SAA3BA,cAA2B,GAAM;EACnC,wBAAwB,IAAAC,mCAAA,GAAxB;EAAA,IAAQC,WAAR,qBAAQA,WAAR;;EACA,yBAAsD,IAAAC,qCAAA,GAAtD;EAAA,IAAQC,YAAR,sBAAQA,YAAR;EAAA,IAAsBC,WAAtB,sBAAsBA,WA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js CHANGED
@@ -1,36 +1,55 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = void 0;
9
+
8
10
  var _react = _interopRequireDefault(require("react"));
11
+
9
12
  var _form = require("@webiny/form");
13
+
10
14
  var _validation = require("@webiny/validation");
15
+
11
16
  var _Button = require("@webiny/ui/Button");
17
+
12
18
  var _Input = require("@webiny/ui/Input");
19
+
13
20
  var _Grid = require("@webiny/ui/Grid");
21
+
14
22
  var _Typography = require("@webiny/ui/Typography");
23
+
15
24
  var _Elevation = require("@webiny/ui/Elevation");
25
+
16
26
  var _Alert = require("@webiny/ui/Alert");
27
+
17
28
  var _Progress = require("@webiny/ui/Progress");
29
+
18
30
  var _useAuthenticator2 = require("@webiny/app-cognito-authenticator/hooks/useAuthenticator");
31
+
19
32
  var _useSignIn2 = require("@webiny/app-cognito-authenticator/hooks/useSignIn");
33
+
20
34
  var _StateContainer = _interopRequireDefault(require("./StateContainer"));
35
+
21
36
  var _StyledComponents = require("./StyledComponents");
37
+
22
38
  var SignIn = function SignIn() {
23
39
  var _useAuthenticator = (0, _useAuthenticator2.useAuthenticator)(),
24
- message = _useAuthenticator.message,
25
- changeState = _useAuthenticator.changeState;
40
+ message = _useAuthenticator.message,
41
+ changeState = _useAuthenticator.changeState;
42
+
26
43
  var _useSignIn = (0, _useSignIn2.useSignIn)(),
27
- signIn = _useSignIn.signIn,
28
- loading = _useSignIn.loading,
29
- error = _useSignIn.error,
30
- shouldRender = _useSignIn.shouldRender;
44
+ signIn = _useSignIn.signIn,
45
+ loading = _useSignIn.loading,
46
+ error = _useSignIn.error,
47
+ shouldRender = _useSignIn.shouldRender;
48
+
31
49
  if (!shouldRender) {
32
50
  return null;
33
51
  }
52
+
34
53
  return /*#__PURE__*/_react.default.createElement(_StateContainer.default, null, /*#__PURE__*/_react.default.createElement(_form.Form, {
35
54
  onSubmit: function onSubmit(data) {
36
55
  /**
@@ -41,7 +60,7 @@ var SignIn = function SignIn() {
41
60
  submitOnEnter: true
42
61
  }, function (_ref) {
43
62
  var Bind = _ref.Bind,
44
- submit = _ref.submit;
63
+ submit = _ref.submit;
45
64
  return /*#__PURE__*/_react.default.createElement(_Elevation.Elevation, {
46
65
  z: 2
47
66
  }, /*#__PURE__*/_react.default.createElement(_StyledComponents.InnerContent, null, loading && /*#__PURE__*/_react.default.createElement(_Progress.CircularProgress, {
@@ -96,5 +115,6 @@ var SignIn = function SignIn() {
96
115
  }, "Forgot password?")))));
97
116
  }));
98
117
  };
118
+
99
119
  var _default = SignIn;
100
120
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"names":["SignIn","useAuthenticator","message","changeState","useSignIn","signIn","loading","error","shouldRender","data","Bind","submit","title","type","text","errorMessage","validation","create","val","cb","toLowerCase","alignRight","ev","alignCenter"],"sources":["SignIn.tsx"],"sourcesContent":["import React from \"react\";\nimport { Form } from \"@webiny/form\";\nimport { validation } from \"@webiny/validation\";\nimport { ButtonPrimary } from \"@webiny/ui/Button\";\nimport { Input } from \"@webiny/ui/Input\";\nimport { Grid, Cell } from \"@webiny/ui/Grid\";\nimport { Typography } from \"@webiny/ui/Typography\";\nimport { Elevation } from \"@webiny/ui/Elevation\";\nimport { Alert } from \"@webiny/ui/Alert\";\nimport { CircularProgress } from \"@webiny/ui/Progress\";\nimport { useAuthenticator } from \"@webiny/app-cognito-authenticator/hooks/useAuthenticator\";\nimport {\n useSignIn,\n UseSignInCallableParams\n} from \"@webiny/app-cognito-authenticator/hooks/useSignIn\";\nimport StateContainer from \"./StateContainer\";\nimport { alignRight, alignCenter, InnerContent, Title, errorMessage } from \"./StyledComponents\";\n\nconst SignIn: React.FC = () => {\n const { message, changeState } = useAuthenticator();\n const { signIn, loading, error, shouldRender } = useSignIn();\n\n if (!shouldRender) {\n return null;\n }\n\n return (\n <StateContainer>\n <Form\n onSubmit={data => {\n /**\n * We are positive that data is UseSignInCallableParams\n */\n return signIn(data as unknown as UseSignInCallableParams);\n }}\n submitOnEnter\n >\n {({ Bind, submit }) => (\n <Elevation z={2}>\n <InnerContent>\n {loading && <CircularProgress label={\"Signing in...\"} />}\n <Title>\n <h1>\n <Typography use=\"headline4\">Sign In</Typography>\n </h1>\n </Title>\n\n {message && !error && (\n <Grid>\n <Cell span={12}>\n <Alert title={message.title} type={message.type}>\n {message.text}\n </Alert>\n </Cell>\n </Grid>\n )}\n\n {error && (\n <Grid>\n <Cell span={12} className={errorMessage}>\n <Alert title=\"Authentication error\" type={\"danger\"}>\n {error.message}\n </Alert>\n </Cell>\n </Grid>\n )}\n\n <Grid>\n <Cell span={12}>\n <Bind\n name=\"username\"\n validators={validation.create(\"required,email\")}\n beforeChange={(val: string, cb: (value: string) => void) =>\n cb(val.toLowerCase())\n }\n >\n <Input label={\"Your e-mail\"} />\n </Bind>\n </Cell>\n <Cell span={12}>\n <Bind\n name=\"password\"\n validators={validation.create(\"required\")}\n >\n <Input type={\"password\"} label={\"Your password\"} />\n </Bind>\n </Cell>\n <Cell span={12} className={alignRight}>\n <ButtonPrimary\n data-testid=\"submit-sign-in-form-button\"\n onClick={ev => {\n submit(ev);\n }}\n >\n {\"Submit\"}\n </ButtonPrimary>\n </Cell>\n <Cell span={12} className={alignCenter}>\n <a href=\"#\" onClick={() => changeState(\"forgotPassword\")}>\n Forgot password?\n </a>\n </Cell>\n </Grid>\n </InnerContent>\n </Elevation>\n )}\n </Form>\n </StateContainer>\n );\n};\n\nexport default SignIn;\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AAEA,IAAMA,MAAgB,GAAG,SAAnBA,MAAgB,GAAS;EAC3B,wBAAiC,IAAAC,mCAAgB,GAAE;IAA3CC,OAAO,qBAAPA,OAAO;IAAEC,WAAW,qBAAXA,WAAW;EAC5B,iBAAiD,IAAAC,qBAAS,GAAE;I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,YAAY,EAAE,sBAACC,GAAW,EAAEC,EAA2B;QAAA,OACnDA,EAAE,CAACD,GAAG,CAACE,WAAW,EAAE,CAAC;MAAA;IACxB,gBAED,6BAAC,YAAK;MAAC,KAAK,EAAE;IAAc,EAAG,CAC5B,CACJ,eACP,6BAAC,UAAI;MAAC,IAAI,EAAE;IAAG,gBACX,6BAAC,IAAI;MACD,IAAI,EAAC,UAAU;MACf,UAAU,EAAEJ,sBAAU,CAACC,MAAM,CAAC,UAAU;IAAE,gBAE1C,6BAAC,YAAK;MAAC,IAAI,EAAE,UAAW;MAAC,KAAK,EAAE;IAAgB,EAAG,CAChD,CACJ,eACP,6BAAC,UAAI;MAAC,IAAI,EAAE,EAAG;MAAC,SAAS,EAAEI;IAAW,gBAClC,6BAAC,qBAAa;MACV,eAAY,4BAA4B;MACxC,OAAO,EAAE,iBAAAC,EAAE,EAAI;QACXX,MAAM,CAACW,EAAE,CAAC;MACd;IAAE,GAED,QAAQ,CACG,CACb,eACP,6BAAC,UAAI;MAAC,IAAI,EAAE,EAAG;MAAC,SAAS,EAAEC;IAAY,gBACnC;MAAG,IAAI,EAAC,GAAG;MAAC,OAAO,EAAE;QAAA,OAAMpB,WAAW,CAAC,gBAAgB,CAAC;MAAA;IAAC,sBAErD,CACD,CACJ,CACI,CACP;EAAA,CACf,CACE,CACM;AAEzB,CAAC;AAAC,eAEaH,MAAM;AAAA"}
1
+ {"version":3,"names":["SignIn","useAuthenticator","message","changeState","useSignIn","signIn","loading","error","shouldRender","data","Bind","submit","title","type","text","errorMessage","validation","create","val","cb","toLowerCase","alignRight","ev","alignCenter"],"sources":["SignIn.tsx"],"sourcesContent":["import React from \"react\";\nimport { Form } from \"@webiny/form\";\nimport { validation } from \"@webiny/validation\";\nimport { ButtonPrimary } from \"@webiny/ui/Button\";\nimport { Input } from \"@webiny/ui/Input\";\nimport { Grid, Cell } from \"@webiny/ui/Grid\";\nimport { Typography } from \"@webiny/ui/Typography\";\nimport { Elevation } from \"@webiny/ui/Elevation\";\nimport { Alert } from \"@webiny/ui/Alert\";\nimport { CircularProgress } from \"@webiny/ui/Progress\";\nimport { useAuthenticator } from \"@webiny/app-cognito-authenticator/hooks/useAuthenticator\";\nimport {\n useSignIn,\n UseSignInCallableParams\n} from \"@webiny/app-cognito-authenticator/hooks/useSignIn\";\nimport StateContainer from \"./StateContainer\";\nimport { alignRight, alignCenter, InnerContent, Title, errorMessage } from \"./StyledComponents\";\n\nconst SignIn: React.FC = () => {\n const { message, changeState } = useAuthenticator();\n const { signIn, loading, error, shouldRender } = useSignIn();\n\n if (!shouldRender) {\n return null;\n }\n\n return (\n <StateContainer>\n <Form\n onSubmit={data => {\n /**\n * We are positive that data is UseSignInCallableParams\n */\n return signIn(data as unknown as UseSignInCallableParams);\n }}\n submitOnEnter\n >\n {({ Bind, submit }) => (\n <Elevation z={2}>\n <InnerContent>\n {loading && <CircularProgress label={\"Signing in...\"} />}\n <Title>\n <h1>\n <Typography use=\"headline4\">Sign In</Typography>\n </h1>\n </Title>\n\n {message && !error && (\n <Grid>\n <Cell span={12}>\n <Alert title={message.title} type={message.type}>\n {message.text}\n </Alert>\n </Cell>\n </Grid>\n )}\n\n {error && (\n <Grid>\n <Cell span={12} className={errorMessage}>\n <Alert title=\"Authentication error\" type={\"danger\"}>\n {error.message}\n </Alert>\n </Cell>\n </Grid>\n )}\n\n <Grid>\n <Cell span={12}>\n <Bind\n name=\"username\"\n validators={validation.create(\"required,email\")}\n beforeChange={(val: string, cb: (value: string) => void) =>\n cb(val.toLowerCase())\n }\n >\n <Input label={\"Your e-mail\"} />\n </Bind>\n </Cell>\n <Cell span={12}>\n <Bind\n name=\"password\"\n validators={validation.create(\"required\")}\n >\n <Input type={\"password\"} label={\"Your password\"} />\n </Bind>\n </Cell>\n <Cell span={12} className={alignRight}>\n <ButtonPrimary\n data-testid=\"submit-sign-in-form-button\"\n onClick={ev => {\n submit(ev);\n }}\n >\n {\"Submit\"}\n </ButtonPrimary>\n </Cell>\n <Cell span={12} className={alignCenter}>\n <a href=\"#\" onClick={() => changeState(\"forgotPassword\")}>\n Forgot password?\n </a>\n </Cell>\n </Grid>\n </InnerContent>\n </Elevation>\n )}\n </Form>\n </StateContainer>\n );\n};\n\nexport default SignIn;\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AAEA,IAAMA,MAAgB,GAAG,SAAnBA,MAAmB,GAAM;EAC3B,wBAAiC,IAAAC,mCAAA,GAAjC;EAAA,IAAQC,OAAR,qBAAQA,OAAR;EAAA,IAAiBC,WAAjB,qBAAiBA,WAAjB;;EACA,iBAAiD,IAAAC,qBAAA,GAAjD;EAAA,IAAQC,MAAR,cAAQA,MAAR;EAAA,IAAgBC,OAAhB,cAAgBA,OAAhB;EAAA,IAAyBC,KAAzB,cAAyBA,KAAzB;EAAA,IAAgCC,YAAhC,cAAgCA,YAAhC;;EAEA,IAAI,CAACA,YAAL,EAAmB;IACf,OAAO,IAAP;EACH;;EAED,oBACI,6BAAC,uBAAD,qBACI,6BAAC,UAAD;IACI,QAAQ,EAAE,kBAAAC,IAAI,EAAI;MACd;AACpB;AACA;MACoB,OAAOJ,MAAM,CAACI,IAAD,CAAb;IACH,CANL;IAOI,aAAa;EAPjB,GASK;IAAA,IAAGC,IAAH,QAAGA,IAAH;IAAA,IAASC,MAAT,QAASA,MAAT;IAAA,oBACG,6BAAC,oBAAD;MAAW,CAAC,EAAE;IAAd,gBACI,6BAAC,8BAAD,QACKL,OAAO,iBAAI,6BAAC,0BAAD;MAAkB,KAAK,EAAE;IAAzB,EADhB,eAEI,6BAAC,uBAAD,qBACI,sDACI,6BAAC,sBAAD;MAAY,GAAG,EAAC;IAAhB,aADJ,CADJ,CAFJ,EAQKJ,OAAO,IAAI,CAACK,KAAZ,iBACG,6BAAC,UAAD,qBACI,6BAAC,UAAD;MAAM,IAAI,EAAE;IAAZ,gBACI,6BAAC,YAAD;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C,GAAR;MAAY,OAAO,EAAE;QAAA,OAAMpB,WAAW,CAAC,gBAAD,CAAjB;MAAA;IAArB,sBADJ,CA9BJ,CA5BJ,CADJ,CADH;EAAA,CATL,CADJ,CADJ;AAmFH,CA3FD;;eA6FeH,M"}
package/views/SignedIn.js CHANGED
@@ -4,12 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
7
8
  var _useSignedIn2 = require("@webiny/app-cognito-authenticator/hooks/useSignedIn");
9
+
8
10
  var SignedIn = function SignedIn(_ref) {
9
11
  var children = _ref.children;
12
+
10
13
  var _useSignedIn = (0, _useSignedIn2.useSignedIn)(),
11
- shouldRender = _useSignedIn.shouldRender;
14
+ shouldRender = _useSignedIn.shouldRender;
15
+
12
16
  return shouldRender ? children : null;
13
17
  };
18
+
14
19
  var _default = SignedIn;
15
20
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"names":["SignedIn","children","useSignedIn","shouldRender"],"sources":["SignedIn.tsx"],"sourcesContent":["import React from \"react\";\nimport { useSignedIn } from \"@webiny/app-cognito-authenticator/hooks/useSignedIn\";\n\nconst SignedIn: React.FC = ({ children }) => {\n const { shouldRender } = useSignedIn();\n\n return shouldRender ? (children as unknown as React.ReactElement) : null;\n};\n\nexport default SignedIn;\n"],"mappings":";;;;;;AACA;AAEA,IAAMA,QAAkB,GAAG,SAArBA,QAAkB,OAAqB;EAAA,IAAfC,QAAQ,QAARA,QAAQ;EAClC,mBAAyB,IAAAC,yBAAW,GAAE;IAA9BC,YAAY,gBAAZA,YAAY;EAEpB,OAAOA,YAAY,GAAIF,QAAQ,GAAqC,IAAI;AAC5E,CAAC;AAAC,eAEaD,QAAQ;AAAA"}
1
+ {"version":3,"names":["SignedIn","children","useSignedIn","shouldRender"],"sources":["SignedIn.tsx"],"sourcesContent":["import React from \"react\";\nimport { useSignedIn } from \"@webiny/app-cognito-authenticator/hooks/useSignedIn\";\n\nconst SignedIn: React.FC = ({ children }) => {\n const { shouldRender } = useSignedIn();\n\n return shouldRender ? (children as unknown as React.ReactElement) : null;\n};\n\nexport default SignedIn;\n"],"mappings":";;;;;;;AACA;;AAEA,IAAMA,QAAkB,GAAG,SAArBA,QAAqB,OAAkB;EAAA,IAAfC,QAAe,QAAfA,QAAe;;EACzC,mBAAyB,IAAAC,yBAAA,GAAzB;EAAA,IAAQC,YAAR,gBAAQA,YAAR;;EAEA,OAAOA,YAAY,GAAIF,QAAJ,GAAiD,IAApE;AACH,CAJD;;eAMeD,Q"}
@@ -1,16 +1,22 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = void 0;
9
+
8
10
  var React = _interopRequireWildcard(require("react"));
11
+
9
12
  var _appAdmin = require("@webiny/app-admin");
13
+
10
14
  var _StyledComponents = require("./StyledComponents");
15
+
11
16
  var StateContainer = function StateContainer(_ref) {
12
17
  var children = _ref.children;
13
18
  return /*#__PURE__*/React.createElement(_StyledComponents.Wrapper, null, /*#__PURE__*/React.createElement(_StyledComponents.LogoWrapper, null, /*#__PURE__*/React.createElement(_appAdmin.Logo, null)), /*#__PURE__*/React.createElement(_StyledComponents.LoginContent, null, children));
14
19
  };
20
+
15
21
  var _default = StateContainer;
16
22
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"names":["StateContainer","children"],"sources":["StateContainer.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { Logo } from \"@webiny/app-admin\";\nimport { LoginContent, LogoWrapper, Wrapper } from \"./StyledComponents\";\n\nconst StateContainer: React.FC = ({ children }) => (\n <Wrapper>\n <LogoWrapper>\n <Logo />\n </LogoWrapper>\n <LoginContent>{children}</LoginContent>\n </Wrapper>\n);\n\nexport default StateContainer;\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAEA,IAAMA,cAAwB,GAAG,SAA3BA,cAAwB;EAAA,IAAMC,QAAQ,QAARA,QAAQ;EAAA,oBACxC,oBAAC,yBAAO,qBACJ,oBAAC,6BAAW,qBACR,oBAAC,cAAI,OAAG,CACE,eACd,oBAAC,8BAAY,QAAEA,QAAQ,CAAgB,CACjC;AAAA,CACb;AAAC,eAEaD,cAAc;AAAA"}
1
+ {"version":3,"names":["StateContainer","children"],"sources":["StateContainer.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { Logo } from \"@webiny/app-admin\";\nimport { LoginContent, LogoWrapper, Wrapper } from \"./StyledComponents\";\n\nconst StateContainer: React.FC = ({ children }) => (\n <Wrapper>\n <LogoWrapper>\n <Logo />\n </LogoWrapper>\n <LoginContent>{children}</LoginContent>\n </Wrapper>\n);\n\nexport default StateContainer;\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEA,IAAMA,cAAwB,GAAG,SAA3BA,cAA2B;EAAA,IAAGC,QAAH,QAAGA,QAAH;EAAA,oBAC7B,oBAAC,yBAAD,qBACI,oBAAC,6BAAD,qBACI,oBAAC,cAAD,OADJ,CADJ,eAII,oBAAC,8BAAD,QAAeA,QAAf,CAJJ,CAD6B;AAAA,CAAjC;;eASeD,c"}
@@ -1,12 +1,16 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.errorMessage = exports.alignRight = exports.alignCenter = exports.Wrapper = exports.Title = exports.LogoWrapper = exports.LoginContent = exports.InnerContent = exports.Footer = void 0;
9
+
8
10
  var _styled = _interopRequireDefault(require("@emotion/styled"));
11
+
9
12
  var _emotion = require("emotion");
13
+
10
14
  var Wrapper = /*#__PURE__*/(0, _styled.default)("section", {
11
15
  target: "exiqwj40",
12
16
  label: "Wrapper"
@@ -1 +1 @@
1
- {"version":3,"names":["Wrapper","styled","display","flexDirection","justifyContent","minHeight","color","LogoWrapper","margin","marginBottom","LoginContent","width","maxWidth","borderRadius","boxShadow","a","textDecoration","fontWeight","InnerContent","position","padding","Footer","textAlign","Title","alignRight","css","alignCenter","errorMessage"],"sources":["StyledComponents.ts"],"sourcesContent":["import styled from \"@emotion/styled\";\nimport { css } from \"emotion\";\n\nexport const Wrapper = styled(\"section\")({\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: \"center\",\n minHeight: \"100vh\",\n color: \"var(--mdc-theme-on-surface)\"\n});\n\nexport const LogoWrapper = styled(\"div\")({\n margin: \"0 auto\",\n marginBottom: 30\n});\n\nexport const LoginContent = styled(\"div\")({\n width: \"100%\",\n maxWidth: 500,\n margin: \"0 auto 25px auto\",\n \".mdc-elevation--z2\": {\n borderRadius: 4,\n boxShadow: \"0 1px 3px 0 rgba(0,0,0,0.15)\"\n },\n a: {\n textDecoration: \"none\",\n color: \"var(--mdc-theme-primary)\",\n fontWeight: 600,\n \"&:hover\": {\n textDecoration: \"underline\"\n }\n }\n});\n\nexport const InnerContent = styled(\"div\")({\n position: \"relative\",\n padding: 25\n});\n\nexport const Footer = styled(\"div\")({\n textAlign: \"center\",\n marginBottom: 75,\n a: {\n textDecoration: \"none\",\n color: \"var(--mdc-theme-primary)\"\n }\n});\n\nexport const Title = styled(\"div\")({\n textAlign: \"center\",\n margin: \"10px 25px\"\n});\n\nexport const alignRight = css({\n textAlign: \"right\"\n});\n\nexport const alignCenter = css({\n textAlign: \"center\"\n});\n\nexport const errorMessage = css({\n color: \"red\"\n});\n"],"mappings":";;;;;;;AAAA;AACA;AAEO,IAAMA,OAAO,oBAAGC,eAAM,EAAC,SAAS;EAAA;EAAA;AAAA,GAAE;EACrCC,OAAO,EAAE,MAAM;EACfC,aAAa,EAAE,QAAQ;EACvBC,cAAc,EAAE,QAAQ;EACxBC,SAAS,EAAE,OAAO;EAClBC,KAAK,EAAE;AACX,CAAC,CAAC;AAAC;AAEI,IAAMC,WAAW,oBAAGN,eAAM,EAAC,KAAK;EAAA;EAAA;AAAA,GAAE;E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
1
+ {"version":3,"names":["Wrapper","styled","display","flexDirection","justifyContent","minHeight","color","LogoWrapper","margin","marginBottom","LoginContent","width","maxWidth","borderRadius","boxShadow","a","textDecoration","fontWeight","InnerContent","position","padding","Footer","textAlign","Title","alignRight","css","alignCenter","errorMessage"],"sources":["StyledComponents.ts"],"sourcesContent":["import styled from \"@emotion/styled\";\nimport { css } from \"emotion\";\n\nexport const Wrapper = styled(\"section\")({\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: \"center\",\n minHeight: \"100vh\",\n color: \"var(--mdc-theme-on-surface)\"\n});\n\nexport const LogoWrapper = styled(\"div\")({\n margin: \"0 auto\",\n marginBottom: 30\n});\n\nexport const LoginContent = styled(\"div\")({\n width: \"100%\",\n maxWidth: 500,\n margin: \"0 auto 25px auto\",\n \".mdc-elevation--z2\": {\n borderRadius: 4,\n boxShadow: \"0 1px 3px 0 rgba(0,0,0,0.15)\"\n },\n a: {\n textDecoration: \"none\",\n color: \"var(--mdc-theme-primary)\",\n fontWeight: 600,\n \"&:hover\": {\n textDecoration: \"underline\"\n }\n }\n});\n\nexport const InnerContent = styled(\"div\")({\n position: \"relative\",\n padding: 25\n});\n\nexport const Footer = styled(\"div\")({\n textAlign: \"center\",\n marginBottom: 75,\n a: {\n textDecoration: \"none\",\n color: \"var(--mdc-theme-primary)\"\n }\n});\n\nexport const Title = styled(\"div\")({\n textAlign: \"center\",\n margin: \"10px 25px\"\n});\n\nexport const alignRight = css({\n textAlign: \"right\"\n});\n\nexport const alignCenter = css({\n textAlign: \"center\"\n});\n\nexport const errorMessage = css({\n color: \"red\"\n});\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEO,IAAMA,OAAO,oBAAGC,eAAH,EAAU,SAAV;EAAA;EAAA;AAAA,GAAqB;EACrCC,OAAO,EAAE,MAD4B;EAErCC,aAAa,EAAE,QAFsB;EAGrCC,cAAc,EAAE,QAHqB;EAIrCC,SAAS,EAAE,OAJ0B;EAKrCC,KAAK,EAAE;AAL8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