@webiny/app-admin-cognito 0.0.0-mt-2 → 0.0.0-unstable.06b2ede40f

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.
Files changed (46) hide show
  1. package/components/Divider.d.ts +2 -0
  2. package/components/Divider.js +16 -0
  3. package/components/Divider.js.map +1 -0
  4. package/components/FederatedProviders.d.ts +44 -0
  5. package/components/FederatedProviders.js +14 -0
  6. package/components/FederatedProviders.js.map +1 -0
  7. package/components/View.d.ts +98 -0
  8. package/components/View.js +66 -0
  9. package/components/View.js.map +1 -0
  10. package/federatedIdentityProviders.d.ts +9 -0
  11. package/federatedIdentityProviders.js +9 -0
  12. package/federatedIdentityProviders.js.map +1 -0
  13. package/index.d.ts +136 -8
  14. package/index.js +130 -150
  15. package/index.js.map +1 -0
  16. package/package.json +22 -29
  17. package/types.js +3 -0
  18. package/types.js.map +1 -0
  19. package/views/FederatedLogin.d.ts +7 -0
  20. package/views/FederatedLogin.js +32 -0
  21. package/views/FederatedLogin.js.map +1 -0
  22. package/views/ForgotPassword.d.ts +2 -3
  23. package/views/ForgotPassword.js +91 -98
  24. package/views/ForgotPassword.js.map +1 -0
  25. package/views/LoggingIn.d.ts +2 -0
  26. package/views/LoggingIn.js +9 -0
  27. package/views/LoggingIn.js.map +1 -0
  28. package/views/RequireNewPassword.d.ts +2 -3
  29. package/views/RequireNewPassword.js +61 -70
  30. package/views/RequireNewPassword.js.map +1 -0
  31. package/views/SetNewPassword.d.ts +2 -3
  32. package/views/SetNewPassword.js +56 -63
  33. package/views/SetNewPassword.js.map +1 -0
  34. package/views/SignIn.d.ts +36 -3
  35. package/views/SignIn.js +94 -82
  36. package/views/SignIn.js.map +1 -0
  37. package/views/SignedIn.d.ts +6 -4
  38. package/views/SignedIn.js +7 -8
  39. package/views/SignedIn.js.map +1 -0
  40. package/views/CheckingUser.d.ts +0 -3
  41. package/views/CheckingUser.js +0 -14
  42. package/views/StateContainer.d.ts +0 -5
  43. package/views/StateContainer.js +0 -12
  44. package/views/StyledComponents.d.ts +0 -10
  45. package/views/StyledComponents.js +0 -74
  46. package/views/webiny-orange-logo.svg +0 -23
package/index.js CHANGED
@@ -1,168 +1,148 @@
1
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
- import _objectSpread from "@babel/runtime/helpers/objectSpread2";
3
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
- var _excluded = ["getIdentityData", "onError"],
5
- _excluded2 = ["id", "displayName", "type", "permissions"];
6
- import _regeneratorRuntime from "@babel/runtime/regenerator";
7
- import React, { useCallback, useEffect } from "react";
1
+ import React, { useCallback, useEffect, useState } from "react";
8
2
  import { Auth } from "@aws-amplify/auth";
9
3
  import { useApolloClient } from "@apollo/react-hooks";
10
4
  import { setContext } from "apollo-link-context";
11
5
  import { plugins } from "@webiny/plugins";
12
6
  import { ApolloLinkPlugin } from "@webiny/app/plugins/ApolloLinkPlugin";
13
7
  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
8
  import { useSecurity } from "@webiny/app-security";
21
-
22
- var createApolloLinkPlugin = function createApolloLinkPlugin() {
23
- return new ApolloLinkPlugin(function () {
24
- return setContext( /*#__PURE__*/function () {
25
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_, _ref) {
26
- var headers, user, idToken;
27
- return _regeneratorRuntime.wrap(function _callee$(_context) {
28
- while (1) {
29
- switch (_context.prev = _context.next) {
30
- case 0:
31
- headers = _ref.headers;
32
- _context.next = 3;
33
- return Auth.currentSession();
34
-
35
- case 3:
36
- user = _context.sent;
37
- idToken = user.getIdToken();
38
-
39
- if (idToken) {
40
- _context.next = 7;
41
- break;
42
- }
43
-
44
- return _context.abrupt("return", {
45
- headers: headers
46
- });
47
-
48
- case 7:
49
- if (!(headers && headers.Authorization)) {
50
- _context.next = 9;
51
- break;
52
- }
53
-
54
- return _context.abrupt("return", {
55
- headers: headers
56
- });
57
-
58
- case 9:
59
- return _context.abrupt("return", {
60
- headers: _objectSpread(_objectSpread({}, headers), {}, {
61
- Authorization: "Bearer ".concat(idToken.getJwtToken())
62
- })
63
- });
64
-
65
- case 10:
66
- case "end":
67
- return _context.stop();
68
- }
69
- }
70
- }, _callee);
71
- }));
72
-
73
- return function (_x, _x2) {
74
- return _ref2.apply(this, arguments);
9
+ import { config as appConfig } from "@webiny/app/config";
10
+ import { SignIn } from "./views/SignIn";
11
+ import { RequireNewPassword } from "./views/RequireNewPassword";
12
+ import { ForgotPassword } from "./views/ForgotPassword";
13
+ import { SetNewPassword } from "./views/SetNewPassword";
14
+ import { SignedIn } from "./views/SignedIn";
15
+ import { LoggingIn } from "./views/LoggingIn";
16
+ import { FederatedProviders } from "./components/FederatedProviders";
17
+ import { View } from "./components/View";
18
+ export const Components = {
19
+ View,
20
+ FederatedProviders,
21
+ SignIn
22
+ };
23
+ const createApolloLinkPlugin = () => {
24
+ return new ApolloLinkPlugin(() => {
25
+ return setContext(async (_, {
26
+ headers
27
+ }) => {
28
+ const user = await Auth.currentSession();
29
+ const idToken = user.getIdToken();
30
+ if (!idToken) {
31
+ return {
32
+ headers
33
+ };
34
+ }
35
+
36
+ // If "Authorization" header is already set, don't overwrite it.
37
+ if (headers && headers.Authorization) {
38
+ return {
39
+ headers
40
+ };
41
+ }
42
+ return {
43
+ headers: {
44
+ ...headers,
45
+ Authorization: `Bearer ${idToken.getJwtToken()}`
46
+ }
75
47
  };
76
- }());
48
+ });
77
49
  });
78
50
  };
79
-
80
- var defaultOptions = {
81
- region: process.env.REACT_APP_USER_POOL_REGION,
82
- userPoolId: process.env.REACT_APP_USER_POOL_ID,
83
- userPoolWebClientId: process.env.REACT_APP_USER_POOL_WEB_CLIENT_ID
51
+ const validatePermissions = permissions => {
52
+ const appPermissions = permissions.filter(p => p.name !== "aacl");
53
+ if (appPermissions.length === 0) {
54
+ throw new Error("You have no permissions on this tenant!");
55
+ }
84
56
  };
85
- export var createAuthentication = function createAuthentication(_ref3) {
86
- var getIdentityData = _ref3.getIdentityData,
87
- onError = _ref3.onError,
88
- config = _objectWithoutProperties(_ref3, _excluded);
89
-
90
- Object.keys(config).forEach(function (key) {
91
- return config[key] === undefined && delete config[key];
57
+ const defaultOptions = {
58
+ region: appConfig.getKey("USER_POOL_REGION", process.env.REACT_APP_USER_POOL_REGION),
59
+ userPoolId: appConfig.getKey("USER_POOL_ID", process.env.REACT_APP_USER_POOL_ID),
60
+ userPoolWebClientId: appConfig.getKey("USER_POOL_WEB_CLIENT_ID", process.env.REACT_APP_USER_POOL_WEB_CLIENT_ID)
61
+ };
62
+ export const createAuthentication = ({
63
+ allowSignInWithCredentials = true,
64
+ getIdentityData,
65
+ onError,
66
+ ...config
67
+ }) => {
68
+ /**
69
+ * TODO @ts-refactor
70
+ */
71
+ // @ts-expect-error
72
+ Object.keys(config).forEach(key => config[key] === undefined && delete config[key]);
73
+ Auth.configure({
74
+ ...defaultOptions,
75
+ ...config
92
76
  });
93
- Auth.configure(_objectSpread(_objectSpread({}, defaultOptions), config));
94
-
95
- var Authentication = function Authentication(props) {
96
- var children = props.children;
97
-
98
- var _useSecurity = useSecurity(),
99
- setIdentity = _useSecurity.setIdentity;
100
-
101
- var client = useApolloClient();
102
- var onToken = useCallback( /*#__PURE__*/function () {
103
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(token) {
104
- var payload, logout, _yield$getIdentityDat, id, displayName, type, permissions, data;
105
-
106
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
107
- while (1) {
108
- switch (_context2.prev = _context2.next) {
109
- case 0:
110
- payload = token.payload, logout = token.logout;
111
- _context2.prev = 1;
112
- _context2.next = 4;
113
- return getIdentityData({
114
- client: client,
115
- payload: payload
116
- });
117
-
118
- case 4:
119
- _yield$getIdentityDat = _context2.sent;
120
- id = _yield$getIdentityDat.id;
121
- displayName = _yield$getIdentityDat.displayName;
122
- type = _yield$getIdentityDat.type;
123
- permissions = _yield$getIdentityDat.permissions;
124
- data = _objectWithoutProperties(_yield$getIdentityDat, _excluded2);
125
- setIdentity(_objectSpread(_objectSpread({
126
- id: id,
127
- displayName: displayName,
128
- type: type,
129
- permissions: permissions
130
- }, data), {}, {
131
- logout: logout
132
- }));
133
- _context2.next = 17;
134
- break;
135
-
136
- case 13:
137
- _context2.prev = 13;
138
- _context2.t0 = _context2["catch"](1);
139
- console.log("ERROR", _context2.t0);
140
-
141
- if (typeof onError === "function") {
142
- onError(_context2.t0);
143
- } else {
144
- console.error(_context2.t0);
145
- }
146
-
147
- case 17:
148
- case "end":
149
- return _context2.stop();
150
- }
151
- }
152
- }, _callee2, null, [[1, 13]]);
153
- }));
154
-
155
- return function (_x3) {
156
- return _ref4.apply(this, arguments);
157
- };
158
- }(), []);
159
- useEffect(function () {
77
+ const Authentication = props => {
78
+ const {
79
+ children
80
+ } = props;
81
+ const [loadingIdentity, setLoadingIdentity] = useState(false);
82
+ const {
83
+ setIdentity,
84
+ setIdTokenProvider
85
+ } = useSecurity();
86
+ const client = useApolloClient();
87
+ const onToken = useCallback(async token => {
88
+ const {
89
+ payload,
90
+ logout
91
+ } = token;
92
+ setLoadingIdentity(true);
93
+ try {
94
+ const {
95
+ id,
96
+ displayName,
97
+ type,
98
+ permissions,
99
+ ...data
100
+ } = await getIdentityData({
101
+ client,
102
+ payload
103
+ });
104
+ setIdentity({
105
+ id,
106
+ displayName,
107
+ type,
108
+ permissions,
109
+ ...data,
110
+ logout: logout || (() => {
111
+ return void 0;
112
+ })
113
+ });
114
+ validatePermissions(permissions);
115
+ } catch (err) {
116
+ console.log("ERROR", err);
117
+ if (typeof onError === "function") {
118
+ onError(err);
119
+ } else {
120
+ console.error(err);
121
+ }
122
+ } finally {
123
+ setLoadingIdentity(false);
124
+ }
125
+ }, []);
126
+ useEffect(() => {
127
+ /**
128
+ * We need to give the security layer a way to fetch the `idToken`, so other network clients can use
129
+ * it when sending requests to external services (APIs, websockets,...).
130
+ */
131
+ setIdTokenProvider(async () => {
132
+ const user = await Auth.currentSession();
133
+ const idToken = user.getIdToken();
134
+ return idToken ? idToken.getJwtToken() : undefined;
135
+ });
160
136
  plugins.register(createApolloLinkPlugin());
161
137
  }, []);
162
138
  return /*#__PURE__*/React.createElement(Authenticator, {
163
139
  onToken: onToken
164
- }, /*#__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));
140
+ }, loadingIdentity ? /*#__PURE__*/React.createElement(LoggingIn, null) : /*#__PURE__*/React.createElement(SignIn, {
141
+ federatedProviders: config.federatedProviders,
142
+ allowSignInWithCredentials: allowSignInWithCredentials
143
+ }), /*#__PURE__*/React.createElement(RequireNewPassword, null), /*#__PURE__*/React.createElement(ForgotPassword, null), /*#__PURE__*/React.createElement(SetNewPassword, null), /*#__PURE__*/React.createElement(SignedIn, null, children));
165
144
  };
166
-
167
145
  return Authentication;
168
- };
146
+ };
147
+
148
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useCallback","useEffect","useState","Auth","useApolloClient","setContext","plugins","ApolloLinkPlugin","Authenticator","useSecurity","config","appConfig","SignIn","RequireNewPassword","ForgotPassword","SetNewPassword","SignedIn","LoggingIn","FederatedProviders","View","Components","createApolloLinkPlugin","_","headers","user","currentSession","idToken","getIdToken","Authorization","getJwtToken","validatePermissions","permissions","appPermissions","filter","p","name","length","Error","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","allowSignInWithCredentials","getIdentityData","onError","Object","keys","forEach","key","undefined","configure","Authentication","props","children","loadingIdentity","setLoadingIdentity","setIdentity","setIdTokenProvider","client","onToken","token","payload","logout","id","displayName","type","data","err","console","log","error","register","createElement","federatedProviders"],"sources":["index.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useState } from \"react\";\nimport { Auth } from \"@aws-amplify/auth\";\nimport type { AuthOptions } from \"@aws-amplify/auth/lib-esm/types\";\nimport type 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 type { SecurityPermission } from \"@webiny/app-security/types\";\nimport type { CognitoIdToken } from \"@webiny/app-cognito-authenticator/types\";\nimport { Authenticator } from \"@webiny/app-cognito-authenticator/Authenticator\";\nimport { useSecurity } from \"@webiny/app-security\";\nimport { config as appConfig } from \"@webiny/app/config\";\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 { LoggingIn } from \"~/views/LoggingIn\";\nimport type { FederatedIdentityProvider } from \"~/federatedIdentityProviders\";\nimport { FederatedProviders } from \"~/components/FederatedProviders\";\nimport { View } from \"~/components/View\";\n\nexport const Components = {\n View,\n FederatedProviders,\n SignIn\n};\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 validatePermissions = (permissions: SecurityPermission[]) => {\n const appPermissions = permissions.filter(p => p.name !== \"aacl\");\n if (appPermissions.length === 0) {\n throw new Error(\"You have no permissions on this tenant!\");\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 allowSignInWithCredentials?: boolean;\n federatedProviders?: FederatedIdentityProvider[];\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.ComponentType<AuthenticationProps>;\n}\n\nexport const createAuthentication: AuthenticationFactory = ({\n allowSignInWithCredentials = true,\n getIdentityData,\n onError,\n ...config\n}) => {\n /**\n * TODO @ts-refactor\n */\n // @ts-expect-error\n Object.keys(config).forEach(key => config[key] === undefined && delete config[key]);\n Auth.configure({ ...defaultOptions, ...config });\n\n const Authentication = (props: AuthenticationProps) => {\n const { children } = props;\n const [loadingIdentity, setLoadingIdentity] = useState(false);\n const { setIdentity, setIdTokenProvider } = 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\n validatePermissions(permissions);\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 /**\n * We need to give the security layer a way to fetch the `idToken`, so other network clients can use\n * it when sending requests to external services (APIs, websockets,...).\n */\n setIdTokenProvider(async () => {\n const user = await Auth.currentSession();\n const idToken = user.getIdToken();\n\n return idToken ? idToken.getJwtToken() : undefined;\n });\n\n plugins.register(createApolloLinkPlugin());\n }, []);\n\n return (\n <Authenticator onToken={onToken}>\n {loadingIdentity ? (\n <LoggingIn />\n ) : (\n <SignIn\n federatedProviders={config.federatedProviders}\n allowSignInWithCredentials={allowSignInWithCredentials}\n />\n )}\n <RequireNewPassword />\n <ForgotPassword />\n <SetNewPassword />\n <SignedIn>{children}</SignedIn>\n </Authenticator>\n );\n };\n\n return Authentication;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC/D,SAASC,IAAI,QAAQ,mBAAmB;AAGxC,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,UAAU,QAAQ,qBAAqB;AAChD,SAASC,OAAO,QAAQ,iBAAiB;AACzC,SAASC,gBAAgB,QAAQ,sCAAsC;AAGvE,SAASC,aAAa,QAAQ,iDAAiD;AAC/E,SAASC,WAAW,QAAQ,sBAAsB;AAClD,SAASC,MAAM,IAAIC,SAAS,QAAQ,oBAAoB;AACxD,SAASC,MAAM;AACf,SAASC,kBAAkB;AAC3B,SAASC,cAAc;AACvB,SAASC,cAAc;AACvB,SAASC,QAAQ;AACjB,SAASC,SAAS;AAElB,SAASC,kBAAkB;AAC3B,SAASC,IAAI;AAEb,OAAO,MAAMC,UAAU,GAAG;EACtBD,IAAI;EACJD,kBAAkB;EAClBN;AACJ,CAAC;AAED,MAAMS,sBAAsB,GAAGA,CAAA,KAAwB;EACnD,OAAO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  "name": "@webiny/app-admin-cognito",
3
- "version": "0.0.0-mt-2",
3
+ "version": "0.0.0-unstable.06b2ede40f",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,50 +13,43 @@
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
15
  "@apollo/react-hooks": "3.1.5",
16
- "@aws-amplify/auth": "4.3.10",
17
- "@emotion/styled": "10.0.27",
18
- "@webiny/app": "0.0.0-mt-2",
19
- "@webiny/app-cognito-authenticator": "0.0.0-mt-2",
20
- "@webiny/app-security": "0.0.0-mt-2",
21
- "@webiny/form": "0.0.0-mt-2",
22
- "@webiny/plugins": "0.0.0-mt-2",
23
- "@webiny/ui": "0.0.0-mt-2",
24
- "@webiny/validation": "0.0.0-mt-2",
16
+ "@aws-amplify/auth": "5.6.15",
17
+ "@webiny/admin-ui": "0.0.0-unstable.06b2ede40f",
18
+ "@webiny/app": "0.0.0-unstable.06b2ede40f",
19
+ "@webiny/app-admin": "0.0.0-unstable.06b2ede40f",
20
+ "@webiny/app-cognito-authenticator": "0.0.0-unstable.06b2ede40f",
21
+ "@webiny/app-security": "0.0.0-unstable.06b2ede40f",
22
+ "@webiny/form": "0.0.0-unstable.06b2ede40f",
23
+ "@webiny/plugins": "0.0.0-unstable.06b2ede40f",
24
+ "@webiny/react-composition": "0.0.0-unstable.06b2ede40f",
25
+ "@webiny/validation": "0.0.0-unstable.06b2ede40f",
25
26
  "apollo-client": "2.6.10",
26
27
  "apollo-link-context": "1.0.20",
27
- "emotion": "10.0.27",
28
- "react": "16.14.0",
29
- "react-dom": "16.14.0"
28
+ "react": "18.2.0",
29
+ "react-dom": "18.2.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@babel/cli": "^7.5.5",
33
- "@babel/core": "^7.5.5",
34
- "@babel/plugin-proposal-class-properties": "^7.5.5",
35
- "@babel/plugin-proposal-throw-expressions": "^7.7.4",
36
- "@babel/preset-env": "^7.5.5",
37
- "@babel/preset-react": "^7.0.0",
38
- "@babel/preset-typescript": "^7.8.3",
39
- "@webiny/cli": "^0.0.0-mt-2",
40
- "@webiny/project-utils": "^0.0.0-mt-2",
41
- "babel-plugin-lodash": "^3.3.4",
42
- "rimraf": "^3.0.2",
43
- "ttypescript": "^1.5.12",
44
- "typescript": "^4.1.3"
32
+ "@webiny/project-utils": "0.0.0-unstable.06b2ede40f",
33
+ "rimraf": "6.0.1",
34
+ "typescript": "5.3.3"
45
35
  },
46
36
  "publishConfig": {
47
37
  "access": "public",
48
38
  "directory": "dist"
49
39
  },
50
40
  "scripts": {
51
- "build": "yarn webiny run build",
52
- "watch": "yarn webiny run watch"
41
+ "build": "node ../cli/bin.js run build",
42
+ "watch": "node ../cli/bin.js run watch"
53
43
  },
54
44
  "adio": {
55
45
  "ignore": {
46
+ "dependencies": [
47
+ "@webiny/react-composition"
48
+ ],
56
49
  "peerDependencies": [
57
50
  "react-dom"
58
51
  ]
59
52
  }
60
53
  },
61
- "gitHead": "3c0dcfb3c22c9f83107fdb97b25014cd03d9db7d"
54
+ "gitHead": "06b2ede40fc2212a70eeafd74afd50b56fb0ce82"
62
55
  }
package/types.js CHANGED
@@ -0,0 +1,3 @@
1
+
2
+
3
+ //# sourceMappingURL=types.js.map
package/types.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":[""],"mappings":"","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import type { FederatedIdentityProvider } from "../federatedIdentityProviders";
3
+ interface FederatedLoginProps {
4
+ providers: FederatedIdentityProvider[];
5
+ }
6
+ export declare const FederatedLogin: ({ providers }: FederatedLoginProps) => React.JSX.Element;
7
+ export {};
@@ -0,0 +1,32 @@
1
+ import React from "react";
2
+ import { Auth } from "@aws-amplify/auth";
3
+ import { federatedIdentityProviders } from "../federatedIdentityProviders";
4
+ import { FederatedProviders } from "../components/FederatedProviders";
5
+ export const FederatedLogin = ({
6
+ providers
7
+ }) => {
8
+ return /*#__PURE__*/React.createElement(FederatedProviders.Container, null, providers.map(({
9
+ name,
10
+ component: Component
11
+ }) => {
12
+ const cognitoProviderName = federatedIdentityProviders[name] ?? name;
13
+ const isCustomProvider = !(name in federatedIdentityProviders);
14
+ const signIn = () => {
15
+ if (isCustomProvider) {
16
+ Auth.federatedSignIn({
17
+ customProvider: cognitoProviderName
18
+ });
19
+ } else {
20
+ Auth.federatedSignIn({
21
+ provider: cognitoProviderName
22
+ });
23
+ }
24
+ };
25
+ return /*#__PURE__*/React.createElement(Component, {
26
+ key: name,
27
+ signIn: signIn
28
+ });
29
+ }));
30
+ };
31
+
32
+ //# sourceMappingURL=FederatedLogin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Auth","federatedIdentityProviders","FederatedProviders","FederatedLogin","providers","createElement","Container","map","name","component","Component","cognitoProviderName","isCustomProvider","signIn","federatedSignIn","customProvider","provider","key"],"sources":["FederatedLogin.tsx"],"sourcesContent":["import React from \"react\";\nimport { Auth } from \"@aws-amplify/auth\";\nimport type { CognitoHostedUIIdentityProvider } from \"@aws-amplify/auth/lib-esm/types/Auth\";\nimport type { FederatedIdentityProvider } from \"~/federatedIdentityProviders\";\nimport { federatedIdentityProviders } from \"~/federatedIdentityProviders\";\nimport { FederatedProviders } from \"~/components/FederatedProviders\";\n\ninterface FederatedLoginProps {\n providers: FederatedIdentityProvider[];\n}\n\nexport const FederatedLogin = ({ providers }: FederatedLoginProps) => {\n return (\n <FederatedProviders.Container>\n {providers.map(({ name, component: Component }) => {\n const cognitoProviderName = federatedIdentityProviders[name] ?? name;\n const isCustomProvider = !(name in federatedIdentityProviders);\n\n const signIn = () => {\n if (isCustomProvider) {\n Auth.federatedSignIn({\n customProvider: cognitoProviderName\n });\n } else {\n Auth.federatedSignIn({\n provider: cognitoProviderName as CognitoHostedUIIdentityProvider\n });\n }\n };\n\n return <Component key={name} signIn={signIn} />;\n })}\n </FederatedProviders.Container>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,QAAQ,mBAAmB;AAGxC,SAASC,0BAA0B;AACnC,SAASC,kBAAkB;AAM3B,OAAO,MAAMC,cAAc,GAAGA,CAAC;EAAEC;AAA+B,CAAC,KAAK;EAClE,oBACIL,KAAA,CAAAM,aAAA,CAACH,kBAAkB,CAACI,SAAS,QACxBF,SAAS,CAACG,GAAG,CAAC,CAAC;IAAEC,IAAI;IAAEC,SAAS,EAAEC;EAAU,CAAC,KAAK;IAC/C,MAAMC,mBAAmB,GAAGV,0BAA0B,CAACO,IAAI,CAAC,IAAIA,IAAI;IACpE,MAAMI,gBAAgB,GAAG,EAAEJ,IAAI,IAAIP,0BAA0B,CAAC;IAE9D,MAAMY,MAAM,GAAGA,CAAA,KAAM;MACjB,IAAID,gBAAgB,EAAE;QAClBZ,IAAI,CAACc,eAAe,CAAC;UACjBC,cAAc,EAAEJ;QACpB,CAAC,CAAC;MACN,CAAC,MAAM;QACHX,IAAI,CAACc,eAAe,CAAC;UACjBE,QAAQ,EAAEL;QACd,CAAC,CAAC;MACN;IACJ,CAAC;IAED,oBAAOZ,KAAA,CAAAM,aAAA,CAACK,SAAS;MAACO,GAAG,EAAET,IAAK;MAACK,MAAM,EAAEA;IAAO,CAAE,CAAC;EACnD,CAAC,CACyB,CAAC;AAEvC,CAAC","ignoreList":[]}
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
- declare const ForgotPassword: () => JSX.Element;
3
- export default ForgotPassword;
1
+ import * as React from "react";
2
+ export declare const ForgotPassword: () => React.JSX.Element | null;