@aws/nx-plugin 0.1.2 → 0.1.4
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/LICENSE-THIRD-PARTY +5976 -0
- package/package.json +3 -2
- package/src/cloudscape-website/app/files/app/src/layouts/App/index.tsx.template +20 -20
- package/src/cloudscape-website/app/files/app/src/main.tsx.template +18 -17
- package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/index.ts.template +2 -2
- package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/static-website.ts.template +6 -4
- package/src/cloudscape-website/app/generator.js +2 -1
- package/src/cloudscape-website/app/generator.js.map +1 -1
- package/src/cloudscape-website/cognito-auth/__snapshots__/generator.spec.ts.snap +1 -2
- package/src/cloudscape-website/cognito-auth/files/app/components/CognitoAuth/index.tsx.template +15 -15
- package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/index.ts.template +2 -2
- package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/user-identity.ts.template +1 -4
- package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/userpool-with-mfa.ts.template +38 -38
- package/src/cloudscape-website/cognito-auth/generator.js +4 -3
- package/src/cloudscape-website/cognito-auth/generator.js.map +1 -1
- package/src/cloudscape-website/runtime-config/__snapshots__/generator.spec.ts.snap +2 -5
- package/src/cloudscape-website/runtime-config/files/app/components/RuntimeConfig/index.tsx.template +12 -8
- package/src/cloudscape-website/runtime-config/generator.js +3 -2
- package/src/cloudscape-website/runtime-config/generator.js.map +1 -1
- package/src/gitlab/generator.js +0 -1
- package/src/gitlab/generator.js.map +1 -1
- package/src/infra/app/files/src/main.ts.template +9 -9
- package/src/infra/app/generator.js +2 -1
- package/src/infra/app/generator.js.map +1 -1
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/trpc/backend/files/backend/src/lambdas/router.ts.template +4 -4
- package/src/trpc/backend/files/common/constructs/src/__apiNameKebabCase__/index.ts.template +69 -44
- package/src/trpc/backend/files/schema/src/index.ts.template +2 -2
- package/src/trpc/backend/generator.js +2 -1
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/trpc/react/files/src/components/TRPCClientProvider/index.tsx.template +21 -21
- package/src/trpc/react/generator.js +2 -1
- package/src/trpc/react/generator.js.map +1 -1
- package/src/utils/files/common/constructs/src/index.ts.template +1 -1
- package/src/utils/files/common/constructs/src/runtime-config/runtime-config.ts.template +4 -4
- package/src/utils/files/common/types/src/index.ts.template +1 -1
- package/src/utils/format.d.ts +10 -0
- package/src/utils/format.js +64 -0
- package/src/utils/format.js.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws/nx-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"nx": "^20.2.2",
|
|
19
19
|
"typescript": "~5.5.4",
|
|
20
20
|
"vite": "^5.4.0",
|
|
21
|
-
"vitest": "^1.6.0"
|
|
21
|
+
"vitest": "^1.6.0",
|
|
22
|
+
"prettier": "^2.8.8"
|
|
22
23
|
},
|
|
23
24
|
"publishConfig": {
|
|
24
25
|
"access": "public"
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
/*! Copyright [Amazon.com](http://amazon.com/), Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
SPDX-License-Identifier: Apache-2.0 */
|
|
3
|
-
import { useCognitoAuthContext } from
|
|
4
|
-
import getBreadcrumbs from
|
|
5
|
-
import NavHeader from
|
|
6
|
-
import * as React from
|
|
7
|
-
import { createContext, useCallback, useEffect, useState } from
|
|
8
|
-
import { NavItems } from
|
|
9
|
-
import Config from
|
|
10
|
-
import Routes from
|
|
3
|
+
import { useCognitoAuthContext } from '@aws-northstar/ui';
|
|
4
|
+
import getBreadcrumbs from '@aws-northstar/ui/components/AppLayout/utils/getBreadcrumbs';
|
|
5
|
+
import NavHeader from '@aws-northstar/ui/components/AppLayout/components/NavHeader';
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import { createContext, useCallback, useEffect, useState } from 'react';
|
|
8
|
+
import { NavItems } from './navitems';
|
|
9
|
+
import Config from '../../config';
|
|
10
|
+
import Routes from '../Routes';
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
13
|
BreadcrumbGroup,
|
|
14
14
|
BreadcrumbGroupProps,
|
|
15
15
|
SideNavigation,
|
|
16
|
-
} from
|
|
16
|
+
} from '@cloudscape-design/components';
|
|
17
17
|
import AppLayout, {
|
|
18
18
|
AppLayoutProps,
|
|
19
|
-
} from
|
|
20
|
-
import { useLocation, useNavigate } from
|
|
19
|
+
} from '@cloudscape-design/components/app-layout';
|
|
20
|
+
import { useLocation, useNavigate } from 'react-router-dom';
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Context for updating/retrieving the AppLayout.
|
|
@@ -37,10 +37,10 @@ const App: React.FC = () => {
|
|
|
37
37
|
const { getAuthenticatedUser } = useCognitoAuthContext();
|
|
38
38
|
|
|
39
39
|
const navigate = useNavigate();
|
|
40
|
-
const [activeHref, setActiveHref] = useState(
|
|
40
|
+
const [activeHref, setActiveHref] = useState('/');
|
|
41
41
|
const [activeBreadcrumbs, setActiveBreadcrumbs] = useState<
|
|
42
42
|
BreadcrumbGroupProps.Item[]
|
|
43
|
-
>([{ text:
|
|
43
|
+
>([{ text: '/', href: '/' }]);
|
|
44
44
|
const [appLayoutProps, setAppLayoutProps] = useState<AppLayoutProps>({});
|
|
45
45
|
const location = useLocation();
|
|
46
46
|
|
|
@@ -50,7 +50,7 @@ const App: React.FC = () => {
|
|
|
50
50
|
|
|
51
51
|
authUser?.getSession(() => {
|
|
52
52
|
authUser.getUserAttributes((_, attributes) => {
|
|
53
|
-
setEmail(attributes?.find((a) => a.Name ===
|
|
53
|
+
setEmail(attributes?.find((a) => a.Name === 'email')?.Value);
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
56
|
}, [getAuthenticatedUser, setUsername, setEmail]);
|
|
@@ -60,12 +60,12 @@ const App: React.FC = () => {
|
|
|
60
60
|
JSON.stringify(appLayoutProps) !== JSON.stringify(props) &&
|
|
61
61
|
setAppLayoutProps(props);
|
|
62
62
|
},
|
|
63
|
-
[appLayoutProps]
|
|
63
|
+
[appLayoutProps]
|
|
64
64
|
);
|
|
65
65
|
|
|
66
66
|
useEffect(() => {
|
|
67
67
|
setActiveHref(location.pathname);
|
|
68
|
-
const breadcrumbs = getBreadcrumbs(location.pathname, location.search,
|
|
68
|
+
const breadcrumbs = getBreadcrumbs(location.pathname, location.search, '/');
|
|
69
69
|
setActiveBreadcrumbs(breadcrumbs);
|
|
70
70
|
}, [location]);
|
|
71
71
|
|
|
@@ -82,7 +82,7 @@ const App: React.FC = () => {
|
|
|
82
82
|
navigate(e.detail.href);
|
|
83
83
|
}
|
|
84
84
|
},
|
|
85
|
-
[navigate, setAppLayoutPropsSafe]
|
|
85
|
+
[navigate, setAppLayoutPropsSafe]
|
|
86
86
|
);
|
|
87
87
|
|
|
88
88
|
return (
|
|
@@ -103,7 +103,7 @@ const App: React.FC = () => {
|
|
|
103
103
|
onSignout={() =>
|
|
104
104
|
new Promise(() => {
|
|
105
105
|
getAuthenticatedUser()?.signOut();
|
|
106
|
-
window.location.href =
|
|
106
|
+
window.location.href = '/';
|
|
107
107
|
})
|
|
108
108
|
}
|
|
109
109
|
/>
|
|
@@ -114,7 +114,7 @@ const App: React.FC = () => {
|
|
|
114
114
|
toolsHide
|
|
115
115
|
navigation={
|
|
116
116
|
<SideNavigation
|
|
117
|
-
header={{ text: Config.applicationName, href:
|
|
117
|
+
header={{ text: Config.applicationName, href: '/' }}
|
|
118
118
|
activeHref={activeHref}
|
|
119
119
|
onFollow={onNavigate}
|
|
120
120
|
items={NavItems}
|
|
@@ -129,4 +129,4 @@ const App: React.FC = () => {
|
|
|
129
129
|
);
|
|
130
130
|
};
|
|
131
131
|
|
|
132
|
-
export default App;
|
|
132
|
+
export default App;
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
/*! Copyright [Amazon.com](http://amazon.com/), Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
SPDX-License-Identifier: Apache-2.0 */
|
|
3
|
-
import { NorthStarThemeProvider } from
|
|
4
|
-
import React from
|
|
5
|
-
import { createRoot } from
|
|
6
|
-
import { BrowserRouter } from
|
|
3
|
+
import { NorthStarThemeProvider } from '@aws-northstar/ui';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { createRoot } from 'react-dom/client';
|
|
6
|
+
import { BrowserRouter } from 'react-router-dom';
|
|
7
7
|
import { I18nProvider } from '@cloudscape-design/components/i18n';
|
|
8
8
|
import messages from '@cloudscape-design/components/i18n/messages/all.en';
|
|
9
|
-
import App from
|
|
9
|
+
import App from './layouts/App';
|
|
10
10
|
|
|
11
|
-
const root = document.getElementById(
|
|
12
|
-
root &&
|
|
13
|
-
|
|
14
|
-
<
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
const root = document.getElementById('root');
|
|
12
|
+
root &&
|
|
13
|
+
createRoot(root).render(
|
|
14
|
+
<React.StrictMode>
|
|
15
|
+
<NorthStarThemeProvider>
|
|
16
|
+
<I18nProvider locale="en" messages={[messages]}>
|
|
17
|
+
<BrowserRouter>
|
|
18
|
+
<App />
|
|
19
|
+
</BrowserRouter>
|
|
20
|
+
</I18nProvider>
|
|
21
|
+
</NorthStarThemeProvider>
|
|
22
|
+
</React.StrictMode>
|
|
23
|
+
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright [Amazon.com](http://amazon.com/), Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
SPDX-License-Identifier: Apache-2.0 */
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
3
|
+
export * from './cloudfront-web-acl.js';
|
|
4
|
+
export * from './static-website.js';
|
|
@@ -109,11 +109,13 @@ export class StaticWebsite extends Construct {
|
|
|
109
109
|
const runtimeConfig = RuntimeConfig.ensure(this).config;
|
|
110
110
|
this.bucketDeployment = new BucketDeployment(this, 'WebsiteDeployment', {
|
|
111
111
|
sources: [
|
|
112
|
-
Source.asset(
|
|
112
|
+
Source.asset(
|
|
113
|
+
url.fileURLToPath(
|
|
114
|
+
new URL('../../../../../<%= websiteContentPath %>', import.meta.url)
|
|
115
|
+
)
|
|
116
|
+
),
|
|
113
117
|
...(Object.keys(runtimeConfig).length > 0
|
|
114
|
-
? [
|
|
115
|
-
Source.jsonData(DEFAULT_RUNTIME_CONFIG_FILENAME, runtimeConfig),
|
|
116
|
-
]
|
|
118
|
+
? [Source.jsonData(DEFAULT_RUNTIME_CONFIG_FILENAME, runtimeConfig)]
|
|
117
119
|
: []),
|
|
118
120
|
],
|
|
119
121
|
destinationBucket: this.websiteBucket,
|
|
@@ -16,6 +16,7 @@ const lodash_kebabcase_1 = tslib_1.__importDefault(require("lodash.kebabcase"));
|
|
|
16
16
|
const ts_project_utils_1 = require("../../ts/lib/ts-project-utils");
|
|
17
17
|
const versions_1 = require("../../utils/versions");
|
|
18
18
|
const paths_1 = require("../../utils/paths");
|
|
19
|
+
const format_1 = require("../../utils/format");
|
|
19
20
|
function appGenerator(tree, schema) {
|
|
20
21
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
21
22
|
var _a, _b;
|
|
@@ -134,7 +135,7 @@ function appGenerator(tree, schema) {
|
|
|
134
135
|
'@cloudscape-design/board-components',
|
|
135
136
|
'react-router-dom',
|
|
136
137
|
]), {});
|
|
137
|
-
yield (0,
|
|
138
|
+
yield (0, format_1.formatFilesInSubtree)(tree, websiteContentPath);
|
|
138
139
|
return () => {
|
|
139
140
|
if (!schema.skipInstall) {
|
|
140
141
|
(0, devkit_1.installPackagesTask)(tree);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/cloudscape-website/app/generator.ts"],"names":[],"mappings":";;AAoCA,oCAiRC;;AArTD;;;GAGG;AACH,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/cloudscape-website/app/generator.ts"],"names":[],"mappings":";;AAoCA,oCAiRC;;AArTD;;;GAGG;AACH,uCAUoB;AACpB,uDAAyD;AACzD,2CAKoB;AAEpB,qCAAiD;AACjD,qEAIuC;AACvC,qDAAwE;AACxE,gFAAyC;AACzC,oEAAmE;AACnE,mDAAoD;AACpD,6CAA0D;AAC1D,+CAA0D;AAE1D,SAAsB,YAAY,CAAC,IAAU,EAAE,MAA0B;;;QACvE,MAAM,cAAc,GAAG,IAAA,6BAAiB,EAAC,IAAI,CAAC,CAAC;QAC/C,MAAM,kBAAkB,GAAG,GAAG,cAAc,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;QAC7D,MAAM,kBAAkB,GAAG,IAAA,0BAAiB,EAC1C,MAAA,MAAM,CAAC,SAAS,mCAAI,GAAG,EACvB,MAAM,CAAC,IAAI,CACZ,CAAC;QAEF,iGAAiG;QACjG,OAAO,CAAC,GAAG,CAAC,8BAA8B,GAAG,MAAM,CAAC;QAEpD,mDAAmD;QACnD,MAAM,aAAa,GAAG,MAAM,CAAC;QAE7B,MAAM,IAAA,4BAAoB,EAAC,IAAI,kCAC1B,MAAM,KACT,IAAI,EAAE,kBAAkB,EACxB,SAAS,EAAE,kBAAkB,EAC7B,OAAO,EAAE,KAAK,EACd,SAAS,EAAE,IAAI,EACf,aAAa,IACb,CAAC;QAEH,IAAA,qCAAkB,EAAC,IAAI,EAAE;YACvB,GAAG,EAAE,kBAAkB;YACvB,kBAAkB;SACnB,CAAC,CAAC;QAEH,MAAM,IAAA,6CAAyB,EAAC,IAAI,CAAC,CAAC;QAEtC,MAAM,oBAAoB,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;YACnB,CAAC;YAED,IAAI,kBAAkB,KAAK,yBAAyB,EAAE,CAAC;gBACrD,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,yBAAyB,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;QAED,IAAA,mBAAU,EACR,IAAI,EACJ,IAAA,0BAAiB,EAAC,kBAAkB,EAAE,eAAe,CAAC,EACtD,CAAC,QAAQ,EAAE,EAAE,CAAC,iCACT,QAAQ,KACX,eAAe,kCACV,QAAQ,CAAC,eAAe,KAC3B,gBAAgB,EAAE,SAAS,EAC3B,MAAM,EAAE,UAAU,OAEpB,CACH,CAAC;QAEF,IAAA,mBAAU,EACR,IAAI,EACJ,IAAA,0BAAiB,EAAC,kBAAkB,EAAE,mBAAmB,CAAC,EAC1D,CAAC,QAAQ,EAAE,EAAE,CAAC,iCACT,QAAQ,KACX,eAAe,kCACV,QAAQ,CAAC,eAAe,KAC3B,GAAG,EAAE,CAAC,KAAK,CAAC,OAEd,CACH,CAAC;QAEF,IAAA,qCAA4B,EAC1B,IAAI,EACJ,IAAA,uBAAY,EAAC;YACX,mBAAmB;YACnB,+BAA+B;YAC/B,qCAAqC;YACrC,kBAAkB;SACnB,CAAC,EACF,EAAE,CACH,CAAC;QAEF,MAAM,IAAA,6BAAoB,EAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;QAErD,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;gBACxB,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;CAAA;AAED,kBAAe,YAAY,CAAC"}
|
|
@@ -229,6 +229,5 @@ export function App() {
|
|
|
229
229
|
|
|
230
230
|
exports[`cognito-auth generator > should update shared constructs index.ts > common/constructs-index 1`] = `
|
|
231
231
|
"export * from './identity/index.js';
|
|
232
|
-
export * from './runtime-config/index.js';
|
|
233
|
-
"
|
|
232
|
+
export * from './runtime-config/index.js';"
|
|
234
233
|
`;
|
package/src/cloudscape-website/cognito-auth/files/app/components/CognitoAuth/index.tsx.template
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*! Copyright [Amazon.com](http://amazon.com/), Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
SPDX-License-Identifier: Apache-2.0 */
|
|
3
|
-
import { CognitoAuth as NorthstarCognitoAuth } from
|
|
4
|
-
import React, { useContext } from
|
|
5
|
-
import Config from
|
|
6
|
-
import { RuntimeConfigContext } from
|
|
3
|
+
import { CognitoAuth as NorthstarCognitoAuth } from '@aws-northstar/ui';
|
|
4
|
+
import React, { useContext } from 'react';
|
|
5
|
+
import Config from '../../config';
|
|
6
|
+
import { RuntimeConfigContext } from '../RuntimeConfig';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Sets up the Cognito auth.
|
|
@@ -24,20 +24,20 @@ const CognitoAuth: React.FC<any> = ({ children }) => {
|
|
|
24
24
|
<%if (allowSignup) {%>allowSignup={true}<% } %>
|
|
25
25
|
signUpAttributes={[
|
|
26
26
|
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
displayName: 'Email',
|
|
28
|
+
name: 'email',
|
|
29
|
+
required: true,
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
displayName: 'Given name',
|
|
33
|
+
name: 'given_name',
|
|
34
|
+
required: true,
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
37
|
+
displayName: 'Last name',
|
|
38
|
+
name: 'family_name',
|
|
39
|
+
required: true,
|
|
40
|
+
},
|
|
41
41
|
]}
|
|
42
42
|
>
|
|
43
43
|
{children}
|
|
@@ -47,4 +47,4 @@ const CognitoAuth: React.FC<any> = ({ children }) => {
|
|
|
47
47
|
);
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
export default CognitoAuth;
|
|
50
|
+
export default CognitoAuth;
|
package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/index.ts.template
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright [Amazon.com](http://amazon.com/), Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
SPDX-License-Identifier: Apache-2.0 */
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
3
|
+
export * from './user-identity.js';
|
|
4
|
+
export * from './userpool-with-mfa.js';
|
|
@@ -26,10 +26,7 @@ export class UserIdentity extends Construct {
|
|
|
26
26
|
// Unless explicitly stated, created a default Cognito User Pool and Web Client.
|
|
27
27
|
this.userPool = new UserPoolWithMfa(this, 'UserPool');
|
|
28
28
|
|
|
29
|
-
this.identityPool = new IdentityPool(
|
|
30
|
-
this,
|
|
31
|
-
'IdentityPool'
|
|
32
|
-
);
|
|
29
|
+
this.identityPool = new IdentityPool(this, 'IdentityPool');
|
|
33
30
|
|
|
34
31
|
const existingClient = this.userPool.node.children.find(
|
|
35
32
|
(e) => e.node.id === WEB_CLIENT_ID && e instanceof UserPoolClient
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/*! Copyright [Amazon.com](http://amazon.com/), Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
SPDX-License-Identifier: Apache-2.0 */
|
|
3
|
-
import { PDKNag } from
|
|
4
|
-
import { Duration, Stack } from
|
|
3
|
+
import { PDKNag } from '@aws/pdk/pdk-nag';
|
|
4
|
+
import { Duration, Stack } from 'aws-cdk-lib';
|
|
5
5
|
import {
|
|
6
6
|
AccountRecovery,
|
|
7
7
|
AdvancedSecurityMode,
|
|
8
8
|
Mfa,
|
|
9
9
|
UserPool,
|
|
10
|
-
} from
|
|
11
|
-
import { Construct } from
|
|
10
|
+
} from 'aws-cdk-lib/aws-cognito';
|
|
11
|
+
import { Construct } from 'constructs';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Configures a UserPool with MFA across SMS/TOTP using sane defaults.
|
|
@@ -16,41 +16,41 @@ import { Construct } from "constructs";
|
|
|
16
16
|
export class UserPoolWithMfa extends UserPool {
|
|
17
17
|
constructor(scope: Construct, id: string) {
|
|
18
18
|
super(scope, id, {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
19
|
+
deletionProtection: true,
|
|
20
|
+
passwordPolicy: {
|
|
21
|
+
minLength: 8,
|
|
22
|
+
requireLowercase: true,
|
|
23
|
+
requireUppercase: true,
|
|
24
|
+
requireDigits: true,
|
|
25
|
+
requireSymbols: true,
|
|
26
|
+
tempPasswordValidity: Duration.days(3),
|
|
27
|
+
},
|
|
28
|
+
mfa: Mfa.REQUIRED,
|
|
29
|
+
mfaSecondFactor: { sms: true, otp: true },
|
|
30
|
+
signInCaseSensitive: false,
|
|
31
|
+
advancedSecurityMode: AdvancedSecurityMode.ENFORCED,
|
|
32
|
+
signInAliases: { username: true, email: true },
|
|
33
|
+
accountRecovery: AccountRecovery.EMAIL_ONLY,
|
|
34
|
+
selfSignUpEnabled: <%= allowSignup %>,
|
|
35
|
+
standardAttributes: {
|
|
36
|
+
phoneNumber: { required: false },
|
|
37
|
+
email: { required: true },
|
|
38
|
+
givenName: { required: true },
|
|
39
|
+
familyName: { required: true },
|
|
40
|
+
},
|
|
41
|
+
autoVerify: {
|
|
42
|
+
email: true,
|
|
43
|
+
phone: true,
|
|
44
|
+
},
|
|
45
|
+
keepOriginal: {
|
|
46
|
+
email: true,
|
|
47
|
+
phone: true,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
50
|
|
|
51
51
|
const stack = Stack.of(this);
|
|
52
52
|
|
|
53
|
-
[
|
|
53
|
+
['AwsSolutions-IAM5', 'AwsPrototyping-IAMNoWildcardPermissions'].forEach(
|
|
54
54
|
(RuleId) => {
|
|
55
55
|
PDKNag.addResourceSuppressionsByPathNoThrow(
|
|
56
56
|
stack,
|
|
@@ -59,8 +59,8 @@ export class UserPoolWithMfa extends UserPool {
|
|
|
59
59
|
{
|
|
60
60
|
id: RuleId,
|
|
61
61
|
reason:
|
|
62
|
-
|
|
63
|
-
appliesTo: [
|
|
62
|
+
'MFA requires sending a text to a users phone number which cannot be known at deployment time.',
|
|
63
|
+
appliesTo: ['Resource::*'],
|
|
64
64
|
},
|
|
65
65
|
]
|
|
66
66
|
);
|
|
@@ -12,6 +12,7 @@ const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
|
12
12
|
const typescript_1 = require("typescript");
|
|
13
13
|
const shared_constructs_1 = require("../../utils/shared-constructs");
|
|
14
14
|
const versions_1 = require("../../utils/versions");
|
|
15
|
+
const format_1 = require("../../utils/format");
|
|
15
16
|
function cognitoAuthGenerator(tree, options) {
|
|
16
17
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
17
18
|
const srcRoot = (0, devkit_1.readProjectConfiguration)(tree, options.project).sourceRoot;
|
|
@@ -38,7 +39,7 @@ function cognitoAuthGenerator(tree, options) {
|
|
|
38
39
|
const sharedConstructsIndexContents = tree
|
|
39
40
|
.read(sharedConstructsIndexTsPath)
|
|
40
41
|
.toString();
|
|
41
|
-
const identityExportDeclaration = typescript_1.factory.createExportDeclaration(undefined, undefined, undefined, typescript_1.factory.createStringLiteral('./identity/index.js'));
|
|
42
|
+
const identityExportDeclaration = typescript_1.factory.createExportDeclaration(undefined, undefined, undefined, typescript_1.factory.createStringLiteral('./identity/index.js', true));
|
|
42
43
|
const updatedIndex = tsquery_1.tsquery
|
|
43
44
|
.map((0, tsquery_1.ast)(sharedConstructsIndexContents), 'SourceFile', (node) => {
|
|
44
45
|
return Object.assign(Object.assign({}, node), { statements: [identityExportDeclaration, ...node.statements] });
|
|
@@ -53,7 +54,7 @@ function cognitoAuthGenerator(tree, options) {
|
|
|
53
54
|
throw new Error(`Can only run this generator on a project which contains ${mainTsxPath}`);
|
|
54
55
|
}
|
|
55
56
|
const mainTsxContents = tree.read(mainTsxPath).toString();
|
|
56
|
-
const authImport = typescript_1.factory.createImportDeclaration(undefined, typescript_1.factory.createImportClause(false, typescript_1.factory.createIdentifier('CognitoAuth'), undefined), typescript_1.factory.createStringLiteral('./components/CognitoAuth'));
|
|
57
|
+
const authImport = typescript_1.factory.createImportDeclaration(undefined, typescript_1.factory.createImportClause(false, typescript_1.factory.createIdentifier('CognitoAuth'), undefined), typescript_1.factory.createStringLiteral('./components/CognitoAuth', true));
|
|
57
58
|
const updatedImports = tsquery_1.tsquery
|
|
58
59
|
.map((0, tsquery_1.ast)(mainTsxContents), 'SourceFile', (node) => {
|
|
59
60
|
return Object.assign(Object.assign({}, node), { statements: [authImport, ...node.statements] });
|
|
@@ -79,7 +80,7 @@ function cognitoAuthGenerator(tree, options) {
|
|
|
79
80
|
if (locatedTargetNode && mainTsxContents !== mainTsxUpdatedContents) {
|
|
80
81
|
tree.write(mainTsxPath, mainTsxUpdatedContents);
|
|
81
82
|
}
|
|
82
|
-
yield (0,
|
|
83
|
+
yield (0, format_1.formatFilesInSubtree)(tree, srcRoot);
|
|
83
84
|
return () => {
|
|
84
85
|
(0, devkit_1.installPackagesTask)(tree);
|
|
85
86
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/cloudscape-website/cognito-auth/generator.ts"],"names":[],"mappings":";;AAwBA,oDAkKC;;AA1LD;;;GAGG;AACH,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/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CAAC;QACJ,CAAC;QAED,IAAI,iBAAiB,IAAI,eAAe,KAAK,sBAAsB,EAAE,CAAC;YACpE,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,sBAAsB,CAAC,CAAC;QAClD,CAAC;QAED,MAAM,IAAA,6BAAoB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAE1C,OAAO,GAAG,EAAE;YACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC;CAAA;AAED,kBAAe,oBAAoB,CAAC"}
|
|
@@ -46,7 +46,7 @@ const RuntimeConfigProvider: React.FC<any> = ({ children }) => {
|
|
|
46
46
|
{children}
|
|
47
47
|
</RuntimeConfigContext.Provider>
|
|
48
48
|
) : (
|
|
49
|
-
<Spinner
|
|
49
|
+
<Spinner />
|
|
50
50
|
);
|
|
51
51
|
};
|
|
52
52
|
|
|
@@ -54,10 +54,7 @@ export default RuntimeConfigProvider;
|
|
|
54
54
|
"
|
|
55
55
|
`;
|
|
56
56
|
|
|
57
|
-
exports[`runtime-config generator > should generate shared constructs > common/constructs-index.ts 1`] = `
|
|
58
|
-
"export * from './runtime-config.js';
|
|
59
|
-
"
|
|
60
|
-
`;
|
|
57
|
+
exports[`runtime-config generator > should generate shared constructs > common/constructs-index.ts 1`] = `"export * from './runtime-config.js';"`;
|
|
61
58
|
|
|
62
59
|
exports[`runtime-config generator > should generate shared constructs > runtime-config.ts 1`] = `
|
|
63
60
|
"/*! Copyright [Amazon.com](http://amazon.com/), Inc. or its affiliates. All Rights Reserved.
|
package/src/cloudscape-website/runtime-config/files/app/components/RuntimeConfig/index.tsx.template
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*! Copyright [Amazon.com](http://amazon.com/), Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
SPDX-License-Identifier: Apache-2.0 */
|
|
3
|
-
import ErrorMessage from
|
|
4
|
-
import { Spinner } from
|
|
5
|
-
import React, { createContext, useEffect, useState } from
|
|
3
|
+
import ErrorMessage from '@aws-northstar/ui/components/CognitoAuth/components/ErrorMessage';
|
|
4
|
+
import { Spinner } from '@cloudscape-design/components';
|
|
5
|
+
import React, { createContext, useEffect, useState } from 'react';
|
|
6
6
|
import type { IRuntimeConfig } from '<%= scopeAlias %>common-types';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -18,11 +18,13 @@ export const RuntimeConfigContext = createContext<IRuntimeConfig | undefined>(
|
|
|
18
18
|
* This assumes a runtime-config.json file is present at '/'.
|
|
19
19
|
*/
|
|
20
20
|
const RuntimeConfigProvider: React.FC<any> = ({ children }) => {
|
|
21
|
-
const [runtimeConfig, setRuntimeConfig] = useState<
|
|
21
|
+
const [runtimeConfig, setRuntimeConfig] = useState<
|
|
22
|
+
IRuntimeConfig | undefined
|
|
23
|
+
>();
|
|
22
24
|
const [error, setError] = useState<string | undefined>();
|
|
23
25
|
|
|
24
26
|
useEffect(() => {
|
|
25
|
-
fetch(
|
|
27
|
+
fetch('/runtime-config.json')
|
|
26
28
|
.then((response) => {
|
|
27
29
|
return response.json();
|
|
28
30
|
})
|
|
@@ -30,7 +32,7 @@ const RuntimeConfigProvider: React.FC<any> = ({ children }) => {
|
|
|
30
32
|
setRuntimeConfig(_runtimeConfig as IRuntimeConfig);
|
|
31
33
|
})
|
|
32
34
|
.catch(() => {
|
|
33
|
-
setError(
|
|
35
|
+
setError('No runtime-config.json detected');
|
|
34
36
|
});
|
|
35
37
|
}, [setRuntimeConfig]);
|
|
36
38
|
|
|
@@ -40,7 +42,9 @@ const RuntimeConfigProvider: React.FC<any> = ({ children }) => {
|
|
|
40
42
|
<RuntimeConfigContext.Provider value={runtimeConfig}>
|
|
41
43
|
{children}
|
|
42
44
|
</RuntimeConfigContext.Provider>
|
|
43
|
-
) :
|
|
45
|
+
) : (
|
|
46
|
+
<Spinner />
|
|
47
|
+
);
|
|
44
48
|
};
|
|
45
49
|
|
|
46
|
-
export default RuntimeConfigProvider;
|
|
50
|
+
export default RuntimeConfigProvider;
|
|
@@ -11,6 +11,7 @@ const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
|
11
11
|
const typescript_1 = require("typescript");
|
|
12
12
|
const shared_constructs_1 = require("../../utils/shared-constructs");
|
|
13
13
|
const npm_scope_1 = require("../../utils/npm-scope");
|
|
14
|
+
const format_1 = require("../../utils/format");
|
|
14
15
|
function runtimeConfigGenerator(tree, options) {
|
|
15
16
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
16
17
|
const srcRoot = (0, devkit_1.readProjectConfiguration)(tree, options.project).sourceRoot;
|
|
@@ -29,7 +30,7 @@ function runtimeConfigGenerator(tree, options) {
|
|
|
29
30
|
yield (0, shared_constructs_1.sharedConstructsGenerator)(tree);
|
|
30
31
|
const npmScopePrefix = (0, npm_scope_1.getNpmScopePrefix)(tree);
|
|
31
32
|
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files', 'app'), srcRoot, Object.assign(Object.assign({}, options), { npmScopePrefix, scopeAlias: (0, npm_scope_1.toScopeAlias)(npmScopePrefix) }));
|
|
32
|
-
const runtimeContextImport = typescript_1.factory.createImportDeclaration(undefined, typescript_1.factory.createImportClause(false, typescript_1.factory.createIdentifier('RuntimeConfigProvider'), undefined), typescript_1.factory.createStringLiteral('./components/RuntimeConfig'));
|
|
33
|
+
const runtimeContextImport = typescript_1.factory.createImportDeclaration(undefined, typescript_1.factory.createImportClause(false, typescript_1.factory.createIdentifier('RuntimeConfigProvider'), undefined), typescript_1.factory.createStringLiteral('./components/RuntimeConfig', true));
|
|
33
34
|
const updatedImports = tsquery_1.tsquery
|
|
34
35
|
.map(mainTsxAst, 'SourceFile', (node) => {
|
|
35
36
|
return Object.assign(Object.assign({}, node), { statements: [runtimeContextImport, ...node.statements] });
|
|
@@ -53,7 +54,7 @@ function runtimeConfigGenerator(tree, options) {
|
|
|
53
54
|
if (locatedTargetNode && mainTsxContents !== mainTsxUpdatedContents) {
|
|
54
55
|
tree.write(mainTsxPath, mainTsxUpdatedContents);
|
|
55
56
|
}
|
|
56
|
-
yield (0,
|
|
57
|
+
yield (0, format_1.formatFilesInSubtree)(tree, mainTsxPath);
|
|
57
58
|
});
|
|
58
59
|
}
|
|
59
60
|
exports.default = runtimeConfigGenerator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/cloudscape-website/runtime-config/generator.ts"],"names":[],"mappings":";;AAiBA,wDA6FC;;AA9GD;;;GAGG;AACH,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/cloudscape-website/runtime-config/generator.ts"],"names":[],"mappings":";;AAiBA,wDA6FC;;AA9GD;;;GAGG;AACH,uCAKoB;AAEpB,uDAAyD;AACzD,2CAA6D;AAC7D,qEAA0E;AAC1E,qDAAwE;AACxE,+CAA0D;AAE1D,SAAsB,sBAAsB,CAC1C,IAAU,EACV,OAAqC;;QAErC,MAAM,OAAO,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC;QAC3E,MAAM,WAAW,GAAG,IAAA,0BAAiB,EAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAE3D,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CACb,2DAA2D,WAAW,EAAE,CACzE,CAAC;QACJ,CAAC;QAED,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC1D,MAAM,UAAU,GAAG,IAAA,aAAG,EAAC,eAAe,CAAC,CAAC;QACxC,MAAM,iBAAiB,GAAG,IAAA,0BAAiB,EACzC,OAAO,EACP,YAAY,EACZ,eAAe,EACf,WAAW,CACZ,CAAC;QAEF,IACE,IAAI,CAAC,MAAM,CAAC,iBAAiB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iBAAM,CAAC;gBACN,iBAAiB,GAAG,IAAI,CAAC;YAC3B,CAAC;YAED,OAAO,oBAAO,CAAC,gBAAgB,CAC7B,oBAAO,CAAC,uBAAuB,CAC7B,oBAAO,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,EACjD,SAAS,EACT,oBAAO,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAChC,EACD,CAAC,IAAI,CAAC,EACN,oBAAO,CAAC,uBAAuB,CAC7B,oBAAO,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,CAClD,CACF,CAAC;QACJ,CAAC,CAAC;aACD,WAAW,EAAE,CAAC;QAEjB,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;QAC5E,CAAC;QAED,IAAI,iBAAiB,IAAI,eAAe,KAAK,sBAAsB,EAAE,CAAC;YACpE,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,sBAAsB,CAAC,CAAC;QAClD,CAAC;QAED,MAAM,IAAA,6BAAoB,EAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAChD,CAAC;CAAA;AAED,kBAAe,sBAAsB,CAAC"}
|
package/src/gitlab/generator.js
CHANGED
|
@@ -10,7 +10,6 @@ const devkit_1 = require("@nx/devkit");
|
|
|
10
10
|
function gitlabGenerator(tree, options) {
|
|
11
11
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
12
12
|
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files'), '.', options);
|
|
13
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
14
13
|
});
|
|
15
14
|
}
|
|
16
15
|
exports.default = gitlabGenerator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/gitlab/generator.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/gitlab/generator.ts"],"names":[],"mappings":";;AAOA,0CAKC;;AAZD;;;GAGG;AACH,uCAAoE;AAGpE,SAAsB,eAAe,CACnC,IAAU,EACV,OAA8B;;QAE9B,IAAA,sBAAa,EAAC,IAAI,EAAE,IAAA,0BAAiB,EAAC,SAAS,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAC3E,CAAC;CAAA;AAED,kBAAe,eAAe,CAAC"}
|