@resistdesign/voltra 3.0.0-alpha.4 → 3.0.0-alpha.41
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/README.md +379 -14
- package/api/DBX/DBXAsserts.d.ts +95 -0
- package/api/DBX/DBXRequest.d.ts +5 -0
- package/api/DBX/DBXRuntime.d.ts +5 -0
- package/api/DBX/DBXScenarioConfig.d.ts +9 -0
- package/api/DBX/DBXSeed.d.ts +124 -0
- package/api/DBX/DBXTypes.d.ts +176 -0
- package/api/DBX/index.d.ts +8 -0
- package/api/DataAccessControl.d.ts +220 -0
- package/api/Indexing/API.d.ts +224 -0
- package/api/Indexing/Cursor.d.ts +101 -0
- package/api/Indexing/Handler/Config.d.ts +39 -0
- package/api/Indexing/Handler.d.ts +166 -0
- package/api/Indexing/Trace.d.ts +54 -0
- package/api/Indexing/Types.d.ts +204 -0
- package/api/Indexing/ddb/AwsSdkV3Adapter.d.ts +8 -0
- package/api/Indexing/ddb/Types.d.ts +209 -0
- package/api/Indexing/docId.d.ts +27 -0
- package/api/Indexing/exact/ExactDdb.d.ts +58 -0
- package/api/Indexing/exact/ExactIndex.d.ts +90 -0
- package/api/Indexing/exact/ExactS3.d.ts +41 -0
- package/api/Indexing/fieldQualification.d.ts +12 -0
- package/api/Indexing/fulltext/FullTextDdbBackend.d.ts +212 -0
- package/api/Indexing/fulltext/FullTextMemoryBackend.d.ts +93 -0
- package/api/Indexing/fulltext/Schema.d.ts +164 -0
- package/api/Indexing/hashUniversal.d.ts +13 -0
- package/api/Indexing/index.d.ts +45 -0
- package/api/Indexing/lossy/LossyDdb.d.ts +43 -0
- package/api/Indexing/lossy/LossyIndex.d.ts +72 -0
- package/api/Indexing/lossy/LossyS3.d.ts +40 -0
- package/api/Indexing/rel/Cursor.d.ts +25 -0
- package/api/Indexing/rel/Handlers.d.ts +144 -0
- package/api/Indexing/rel/RelationalDdb.d.ts +169 -0
- package/api/Indexing/rel/RelationalInMemoryBackend.d.ts +38 -0
- package/api/Indexing/rel/Types.d.ts +69 -0
- package/api/Indexing/structured/Cursor.d.ts +26 -0
- package/api/Indexing/structured/Handlers.d.ts +128 -0
- package/api/Indexing/structured/SearchStructured.d.ts +44 -0
- package/api/Indexing/structured/StructuredDdb.d.ts +184 -0
- package/api/Indexing/structured/StructuredDdbBackend.d.ts +112 -0
- package/api/Indexing/structured/StructuredInMemoryBackend.d.ts +40 -0
- package/api/Indexing/structured/StructuredInMemoryIndex.d.ts +61 -0
- package/api/Indexing/structured/StructuredStringLike.d.ts +54 -0
- package/api/Indexing/structured/StructuredWriter.d.ts +74 -0
- package/api/Indexing/structured/Types.d.ts +126 -0
- package/api/Indexing/structured/index.d.ts +9 -0
- package/api/Indexing/tokenize.d.ts +31 -0
- package/api/ORM/DACUtils.d.ts +270 -0
- package/api/ORM/ListItemUtils.d.ts +40 -0
- package/api/ORM/ORMRouteMap.d.ts +55 -0
- package/api/ORM/TypeInfoORMService.d.ts +740 -0
- package/api/ORM/drivers/DynamoDBDataItemDBDriver/ConfigTypes.d.ts +229 -0
- package/api/ORM/drivers/DynamoDBDataItemDBDriver.d.ts +89 -0
- package/api/ORM/drivers/InMemoryDataItemDBDriver/ConfigTypes.d.ts +4 -0
- package/api/ORM/drivers/InMemoryDataItemDBDriver.d.ts +55 -0
- package/api/ORM/drivers/InMemoryFileItemDBDriver/ConfigTypes.d.ts +13 -0
- package/api/ORM/drivers/InMemoryFileItemDBDriver.d.ts +98 -0
- package/api/ORM/drivers/InMemoryItemRelationshipDBDriver.d.ts +16 -0
- package/api/ORM/drivers/IndexingRelationshipDriver.d.ts +123 -0
- package/api/ORM/drivers/S3FileItemDBDriver/ConfigTypes.d.ts +322 -0
- package/api/ORM/drivers/S3FileItemDBDriver/S3FileDriver.d.ts +118 -0
- package/api/ORM/drivers/S3FileItemDBDriver.d.ts +71 -0
- package/api/ORM/drivers/common/SupportedTypeInfoORMDBDrivers.d.ts +36 -0
- package/api/ORM/drivers/common/Types.d.ts +197 -0
- package/api/ORM/drivers/common/index.d.ts +2 -0
- package/api/ORM/drivers/index.d.ts +8 -0
- package/api/ORM/index.d.ts +9 -0
- package/api/ORM/indexing/criteriaToStructuredWhere.d.ts +22 -0
- package/api/Router/AWS.d.ts +80 -0
- package/api/Router/Auth.d.ts +14 -0
- package/api/Router/CORS.d.ts +66 -0
- package/api/Router/Types.d.ts +138 -0
- package/api/Router/index.d.ts +89 -0
- package/api/index.d.ts +72 -6
- package/api/index.js +3291 -1954
- package/app/forms/Engine.d.ts +23 -0
- package/app/forms/UI.d.ts +83 -0
- package/app/forms/core/createAutoField.d.ts +43 -0
- package/app/forms/core/createFormRenderer.d.ts +25 -0
- package/app/forms/core/getFieldKind.d.ts +14 -0
- package/app/forms/core/index.d.ts +11 -0
- package/app/forms/core/mergeSuites.d.ts +23 -0
- package/app/forms/core/resolveSuite.d.ts +15 -0
- package/app/forms/core/types.d.ts +180 -0
- package/app/forms/index.d.ts +9 -0
- package/app/forms/types.d.ts +137 -0
- package/app/helpers/styled.d.ts +3 -0
- package/app/index.d.ts +102 -5
- package/app/index.js +98 -327
- package/app/utils/ApplicationState.d.ts +167 -0
- package/app/utils/ApplicationStateLoader.d.ts +86 -0
- package/app/utils/Controller.d.ts +10 -0
- package/app/utils/Debug.d.ts +14 -0
- package/app/utils/EasyLayout.d.ts +89 -0
- package/app/utils/History.d.ts +165 -0
- package/app/utils/Route.d.ts +173 -0
- package/app/utils/RouteHistory.d.ts +27 -0
- package/app/utils/Service.d.ts +45 -0
- package/app/utils/TypeInfoORMAPIUtils.d.ts +94 -0
- package/app/utils/TypeInfoORMClient.d.ts +103 -0
- package/app/utils/UniversalRouteAdapter.d.ts +73 -0
- package/app/utils/easy-layout/computeAreaBounds.d.ts +5 -0
- package/app/utils/easy-layout/computeTracks.d.ts +16 -0
- package/app/utils/easy-layout/index.d.ts +5 -0
- package/app/utils/easy-layout/parseTemplate.d.ts +12 -0
- package/app/utils/easy-layout/types.d.ts +52 -0
- package/app/utils/easy-layout/validateAreas.d.ts +5 -0
- package/app/utils/index.d.ts +24 -0
- package/build/TypeMapping.d.ts +17 -0
- package/build/TypeParsing.d.ts +10 -0
- package/build/index.d.ts +15 -0
- package/build/index.js +569 -0
- package/chunk-2MOLWZMQ.js +71 -0
- package/chunk-7AMEFPPP.js +78 -0
- package/chunk-ATO2455Q.js +258 -0
- package/chunk-DT6WWJUI.js +1185 -0
- package/chunk-I2KLQ2HA.js +19 -0
- package/chunk-TJFTWPXQ.js +39 -0
- package/chunk-WNFRDIBW.js +121 -0
- package/chunk-YCTVEW2I.js +546 -0
- package/common/CommandLine/collectRequiredEnvironmentVariables.d.ts +9 -0
- package/common/CommandLine/index.d.ts +6 -0
- package/common/HelperTypes.d.ts +9 -0
- package/common/IdGeneration/getSimpleId.d.ts +8 -0
- package/common/IdGeneration/index.d.ts +1 -0
- package/common/ItemRelationshipInfoTypes.d.ts +64 -0
- package/common/ItemRelationships/ItemRelationshipValidation.d.ts +21 -0
- package/common/ItemRelationships/index.d.ts +2 -0
- package/common/Logging/Utils.d.ts +10 -0
- package/common/Logging/index.d.ts +1 -0
- package/common/Routing.d.ts +81 -0
- package/common/SearchTypes.d.ts +227 -0
- package/common/SearchUtils.d.ts +55 -0
- package/common/SearchValidation.d.ts +27 -0
- package/common/StringTransformers.d.ts +28 -0
- package/common/Testing/CLI.d.ts +6 -0
- package/common/Testing/Types.d.ts +216 -0
- package/common/Testing/Utils.d.ts +112 -0
- package/common/Testing/index.d.ts +8 -0
- package/common/TypeInfoDataItemUtils.d.ts +39 -0
- package/{Types-C7XjUjoF.d.ts → common/TypeInfoORM/Types.d.ts} +117 -15
- package/common/TypeInfoORM/index.d.ts +3 -0
- package/common/TypeParsing/Constants.d.ts +4 -0
- package/common/TypeParsing/ParsingUtils/Constants.d.ts +8 -0
- package/common/TypeParsing/ParsingUtils/checkType.d.ts +14 -0
- package/common/TypeParsing/ParsingUtils/checkUnionType.d.ts +12 -0
- package/common/TypeParsing/ParsingUtils/extractCommentTags.d.ts +8 -0
- package/common/TypeParsing/ParsingUtils/extractLiteralValues.d.ts +12 -0
- package/common/TypeParsing/ParsingUtils/extractTypeDetails.d.ts +14 -0
- package/common/TypeParsing/ParsingUtils/getPrimaryFieldForTypeInfo.d.ts +18 -0
- package/common/TypeParsing/ParsingUtils/getTypeInfo.d.ts +9 -0
- package/common/TypeParsing/ParsingUtils/getTypeInfoField.d.ts +9 -0
- package/common/TypeParsing/ParsingUtils/getTypeInfoFromAliasType.d.ts +11 -0
- package/common/TypeParsing/ParsingUtils/getTypeInfoFromFieldFilter.d.ts +12 -0
- package/common/TypeParsing/ParsingUtils/getTypeInfoFromTypeAlias.d.ts +11 -0
- package/common/TypeParsing/ParsingUtils/getTypeKeyword.d.ts +9 -0
- package/common/TypeParsing/ParsingUtils/getUnionOrIntersectionTypeInfo.d.ts +11 -0
- package/common/TypeParsing/ParsingUtils/getUnionOrLiteralStringValues.d.ts +8 -0
- package/common/TypeParsing/TypeInfo.d.ts +222 -0
- package/common/TypeParsing/Utils.d.ts +47 -0
- package/common/TypeParsing/Validation.d.ts +327 -0
- package/common/TypeParsing/index.d.ts +8 -0
- package/common/index.d.ts +40 -4
- package/common/index.js +25 -1737
- package/{index-BkFZlfit.d.ts → iac/SimpleCFT.d.ts} +5 -25
- package/iac/index.d.ts +40 -2
- package/iac/index.js +2 -1661
- package/iac/packs/auth.d.ts +131 -0
- package/iac/packs/build/utils.d.ts +289 -0
- package/iac/packs/build.d.ts +92 -0
- package/iac/packs/cdn.d.ts +33 -0
- package/iac/packs/cloud-function.d.ts +67 -0
- package/iac/packs/database.d.ts +32 -0
- package/iac/packs/dns.d.ts +34 -0
- package/iac/packs/file-storage.d.ts +46 -0
- package/iac/packs/gateway.d.ts +82 -0
- package/iac/packs/index.d.ts +60 -1
- package/iac/packs/index.js +391 -594
- package/iac/packs/repo.d.ts +28 -0
- package/iac/packs/ssl-certificate.d.ts +28 -0
- package/iac/types/Constants.d.ts +24 -0
- package/{index-DcvJOZ_c.d.ts → iac/types/IaCTypes.d.ts} +23 -1018
- package/iac/types/Renderers.d.ts +96 -0
- package/iac/types/Types.d.ts +131 -0
- package/iac/types/Utils.d.ts +9 -0
- package/iac/types/generate.d.ts +1 -0
- package/iac/utils/index.d.ts +87 -0
- package/iac/utils/patch-utils.d.ts +66 -0
- package/iac-packs/index.d.ts +6 -0
- package/native/forms/UI.d.ts +73 -0
- package/native/forms/createNativeFormRenderer.d.ts +21 -0
- package/native/forms/index.d.ts +25 -0
- package/native/forms/primitives/index.d.ts +38 -0
- package/native/forms/suite.d.ts +15 -0
- package/native/index.d.ts +19 -0
- package/native/index.js +748 -0
- package/native/testing/react-native.d.ts +46 -0
- package/native/utils/EasyLayout.d.ts +88 -0
- package/native/utils/History.d.ts +102 -0
- package/native/utils/Route.d.ts +80 -0
- package/native/utils/index.d.ts +20 -0
- package/package.json +54 -21
- package/web/forms/UI.d.ts +74 -0
- package/web/forms/createWebFormRenderer.d.ts +21 -0
- package/web/forms/index.d.ts +9 -0
- package/web/forms/primitives/index.d.ts +21 -0
- package/web/forms/suite.d.ts +15 -0
- package/web/index.d.ts +15 -0
- package/web/index.js +668 -0
- package/web/utils/EasyLayout.d.ts +47 -0
- package/web/utils/Route.d.ts +16 -0
- package/web/utils/index.d.ts +7 -0
- package/SearchTypes-DjN6YQzE.d.ts +0 -577
- package/Validation-CFP59oIP.d.ts +0 -226
- package/index-C3-iD9Mh.d.ts +0 -690
- package/index-DZ2BB4iX.d.ts +0 -5357
- package/index-IokxSNxm.d.ts +0 -745
- package/index.d.ts +0 -13
- package/index.js +0 -10973
package/iac/packs/index.js
CHANGED
|
@@ -1,441 +1,308 @@
|
|
|
1
|
+
import { createResourcePack, SimpleCFT } from '../../chunk-ATO2455Q.js';
|
|
2
|
+
import '../../chunk-I2KLQ2HA.js';
|
|
1
3
|
import YAML from 'yaml';
|
|
2
4
|
|
|
3
|
-
// src/iac/
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
strategy: specificKeyMergeStrategy = DEFAULT_MERGE_STRATEGY,
|
|
15
|
-
data: specificKeyMergeStrategyData = void 0
|
|
16
|
-
} = {},
|
|
17
|
-
[arrayIndexWildcardValuePathString]: {
|
|
18
|
-
strategy: arrayIndexWildcardMergeStrategy = DEFAULT_MERGE_STRATEGY,
|
|
19
|
-
data: arrayIndexWildcardMergeStrategyData = void 0
|
|
20
|
-
} = {}
|
|
21
|
-
} = mergeStrategyMap;
|
|
22
|
-
const mergeStrategy = valuePathString in mergeStrategyMap ? specificKeyMergeStrategy : arrayIndexWildcardMergeStrategy;
|
|
23
|
-
const mergeStrategyData = valuePathString in mergeStrategyMap ? specificKeyMergeStrategyData : arrayIndexWildcardMergeStrategyData;
|
|
24
|
-
let mergedValue = typeof newValue !== "undefined" ? newValue : existingValue;
|
|
25
|
-
if (mergeStrategy !== "replace") {
|
|
26
|
-
if (isConstructedFrom(existingValue, Array) && isConstructedFrom(newValue, Array)) {
|
|
27
|
-
if (mergeStrategy === "accumulate") {
|
|
28
|
-
mergedValue = [...existingValue, ...newValue];
|
|
29
|
-
} else if (mergeStrategy === "accumulate-unique") {
|
|
30
|
-
mergedValue = [
|
|
31
|
-
...existingValue,
|
|
32
|
-
...newValue.filter(
|
|
33
|
-
(item) => existingValue.indexOf(item) === -1
|
|
34
|
-
)
|
|
35
|
-
];
|
|
36
|
-
} else if (mergeStrategy === "accumulate-unique-by") {
|
|
37
|
-
const existingItemMap = {};
|
|
38
|
-
const newItemMap = {};
|
|
39
|
-
for (let i = 0; i < existingValue.length; i++) {
|
|
40
|
-
const existingItem = existingValue[i];
|
|
41
|
-
if (existingItem && typeof existingItem === "object") {
|
|
42
|
-
const identifier = mergeStrategyData instanceof Function ? mergeStrategyData(existingItem) : existingItem[mergeStrategyData];
|
|
43
|
-
existingItemMap[identifier] = existingItem;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
for (let j = 0; j < newValue.length; j++) {
|
|
47
|
-
const newItem = newValue[j];
|
|
48
|
-
if (newItem && typeof newItem === "object") {
|
|
49
|
-
const identifier = mergeStrategyData instanceof Function ? mergeStrategyData(newItem) : newItem[mergeStrategyData];
|
|
50
|
-
newItemMap[identifier] = newItem;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
mergedValue = Object.keys({
|
|
54
|
-
...existingItemMap,
|
|
55
|
-
...newItemMap
|
|
56
|
-
}).map(
|
|
57
|
-
(id, index) => mergeValues(
|
|
58
|
-
[...valuePathArray, index],
|
|
59
|
-
existingItemMap[id],
|
|
60
|
-
newItemMap[id],
|
|
61
|
-
mergeStrategyMap
|
|
62
|
-
)
|
|
63
|
-
);
|
|
64
|
-
} else if (mergeStrategy === "transpose") {
|
|
65
|
-
const fullLength = Math.max(existingValue.length, newValue.length);
|
|
66
|
-
mergedValue = [...new Array(fullLength)].map(
|
|
67
|
-
(_empty, index) => mergeValues(
|
|
68
|
-
[...valuePathArray, index],
|
|
69
|
-
existingValue[index],
|
|
70
|
-
newValue[index],
|
|
71
|
-
mergeStrategyMap
|
|
72
|
-
)
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
} else if (isConstructedFrom(existingValue, Object) && isConstructedFrom(newValue, Object)) {
|
|
76
|
-
mergedValue = Object.keys({ ...existingValue, ...newValue }).reduce(
|
|
77
|
-
(acc, k) => ({
|
|
78
|
-
...acc,
|
|
79
|
-
[k]: mergeValues(
|
|
80
|
-
[...valuePathArray, k],
|
|
81
|
-
existingValue[k],
|
|
82
|
-
newValue[k],
|
|
83
|
-
mergeStrategyMap
|
|
84
|
-
)
|
|
85
|
-
}),
|
|
86
|
-
{}
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return mergedValue;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
// src/iac/utils/index.ts
|
|
94
|
-
var addParameter = (parameterInfo, template) => {
|
|
95
|
-
const { ParameterId, Parameter, Label, Group } = parameterInfo;
|
|
96
|
-
const {
|
|
97
|
-
Parameters,
|
|
98
|
-
Metadata: {
|
|
99
|
-
"AWS::CloudFormation::Interface": {
|
|
100
|
-
ParameterGroups = [],
|
|
101
|
-
ParameterLabels = {}
|
|
102
|
-
} = {}
|
|
103
|
-
} = {}
|
|
104
|
-
} = template;
|
|
105
|
-
let NewParameterGroups = ParameterGroups;
|
|
106
|
-
if (Group) {
|
|
107
|
-
const GroupObject = ParameterGroups.filter(
|
|
108
|
-
(g) => g.Label?.default === Group
|
|
109
|
-
)[0];
|
|
110
|
-
NewParameterGroups = GroupObject ? ParameterGroups.map(
|
|
111
|
-
(g) => g.Label?.default === Group ? {
|
|
112
|
-
...g,
|
|
113
|
-
Parameters: [...g.Parameters || [], ParameterId]
|
|
114
|
-
} : g
|
|
115
|
-
) : [
|
|
116
|
-
...ParameterGroups,
|
|
117
|
-
{
|
|
118
|
-
Label: {
|
|
119
|
-
default: Group
|
|
120
|
-
},
|
|
121
|
-
Parameters: [ParameterId]
|
|
122
|
-
}
|
|
123
|
-
];
|
|
124
|
-
}
|
|
125
|
-
return {
|
|
126
|
-
...template,
|
|
127
|
-
Parameters: {
|
|
128
|
-
...Parameters,
|
|
129
|
-
[ParameterId]: Parameter
|
|
130
|
-
},
|
|
131
|
-
Metadata: {
|
|
132
|
-
...template.Metadata,
|
|
133
|
-
"AWS::CloudFormation::Interface": {
|
|
134
|
-
...template?.Metadata?.["AWS::CloudFormation::Interface"],
|
|
135
|
-
ParameterGroups: NewParameterGroups,
|
|
136
|
-
ParameterLabels: {
|
|
137
|
-
...ParameterLabels,
|
|
138
|
-
[ParameterId]: {
|
|
139
|
-
default: Label
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
};
|
|
146
|
-
var addParameters = (parameters, template) => parameters.reduce((acc, p) => addParameter(p, acc), template);
|
|
147
|
-
var patchTemplate = (patch, template) => mergeValues([], template, patch, {
|
|
148
|
-
[getValuePathString([
|
|
149
|
-
// Parameter Groups
|
|
150
|
-
"Metadata",
|
|
151
|
-
"AWS::CloudFormation::Interface",
|
|
152
|
-
"ParameterGroups"
|
|
153
|
-
])]: {
|
|
154
|
-
strategy: "accumulate-unique-by",
|
|
155
|
-
data: (pG) => pG?.Label?.default
|
|
156
|
-
},
|
|
157
|
-
[getValuePathString([
|
|
158
|
-
// Parameter Group Parameter Ids
|
|
159
|
-
"Metadata",
|
|
160
|
-
"AWS::CloudFormation::Interface",
|
|
161
|
-
"ParameterGroups",
|
|
162
|
-
"#",
|
|
163
|
-
"Parameters"
|
|
164
|
-
])]: {
|
|
165
|
-
strategy: "accumulate-unique"
|
|
166
|
-
}
|
|
5
|
+
// src/iac/packs/auth.ts
|
|
6
|
+
var resolveUserManagementIds = (baseId, ids) => ({
|
|
7
|
+
userPool: ids?.userPool || baseId,
|
|
8
|
+
userPoolClient: ids?.userPoolClient || `${baseId}Client`,
|
|
9
|
+
identityPool: ids?.identityPool || `${baseId}IdentityPool`,
|
|
10
|
+
authRole: ids?.authRole || `${baseId}AuthRole`,
|
|
11
|
+
unauthRole: ids?.unauthRole || `${baseId}UnauthRole`,
|
|
12
|
+
roleAttachment: ids?.roleAttachment || `${baseId}IdentityPoolRoles`,
|
|
13
|
+
domain: ids?.domain || `${baseId}Domain`,
|
|
14
|
+
domainRecord: ids?.domainRecord || `${baseId}DomainRecord`,
|
|
15
|
+
baseDomainRecord: ids?.baseDomainRecord || `${baseId}BaseDomainRecord`
|
|
167
16
|
});
|
|
168
|
-
var
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
// src/iac/packs/auth/user-management.ts
|
|
174
|
-
var addUserManagement = createResourcePack(
|
|
175
|
-
({
|
|
176
|
-
id,
|
|
17
|
+
var addAuth = createResourcePack((config) => {
|
|
18
|
+
const {
|
|
19
|
+
userManagementId,
|
|
20
|
+
userManagementIds,
|
|
177
21
|
authRoleName,
|
|
178
22
|
unauthRoleName,
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
23
|
+
apiCloudFunctionGatewayId,
|
|
24
|
+
apiStageName,
|
|
25
|
+
adminGroupId,
|
|
26
|
+
userManagementAdminGroupName
|
|
27
|
+
} = config;
|
|
28
|
+
const resolvedIds = resolveUserManagementIds(
|
|
29
|
+
userManagementId,
|
|
30
|
+
userManagementIds
|
|
31
|
+
);
|
|
32
|
+
const isUserPoolDomainEnabled = config.enableUserPoolDomain !== false;
|
|
33
|
+
const supportedIdentityProviders = isUserPoolDomainEnabled && "supportedIdentityProviders" in config && config.supportedIdentityProviders && config.supportedIdentityProviders.length > 0 ? config.supportedIdentityProviders : ["COGNITO"];
|
|
34
|
+
const apiRoleConfig = {
|
|
35
|
+
[resolvedIds.roleAttachment]: {
|
|
36
|
+
Type: "AWS::Cognito::IdentityPoolRoleAttachment",
|
|
37
|
+
Properties: {
|
|
38
|
+
IdentityPoolId: {
|
|
39
|
+
Ref: resolvedIds.identityPool
|
|
40
|
+
},
|
|
41
|
+
Roles: {
|
|
42
|
+
authenticated: {
|
|
43
|
+
"Fn::GetAtt": [resolvedIds.authRole, "Arn"]
|
|
194
44
|
},
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
"Fn::GetAtt": [`${id}AuthRole`, "Arn"]
|
|
198
|
-
},
|
|
199
|
-
unauthenticated: {
|
|
200
|
-
"Fn::GetAtt": [`${id}UnauthRole`, "Arn"]
|
|
201
|
-
}
|
|
45
|
+
unauthenticated: {
|
|
46
|
+
"Fn::GetAtt": [resolvedIds.unauthRole, "Arn"]
|
|
202
47
|
}
|
|
203
48
|
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
Effect: "Allow",
|
|
215
|
-
Principal: {
|
|
216
|
-
Federated: "cognito-identity.amazonaws.com"
|
|
217
|
-
},
|
|
218
|
-
Action: ["sts:AssumeRoleWithWebIdentity"],
|
|
219
|
-
Condition: {
|
|
220
|
-
StringEquals: {
|
|
221
|
-
"cognito-identity.amazonaws.com:aud": {
|
|
222
|
-
Ref: `${id}IdentityPool`
|
|
223
|
-
}
|
|
224
|
-
},
|
|
225
|
-
"ForAnyValue:StringLike": {
|
|
226
|
-
"cognito-identity.amazonaws.com:amr": "authenticated"
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
]
|
|
231
|
-
},
|
|
232
|
-
Policies: [
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
[resolvedIds.authRole]: {
|
|
52
|
+
Type: "AWS::IAM::Role",
|
|
53
|
+
Properties: {
|
|
54
|
+
RoleName: authRoleName,
|
|
55
|
+
Path: "/",
|
|
56
|
+
AssumeRolePolicyDocument: {
|
|
57
|
+
Version: "2012-10-17",
|
|
58
|
+
Statement: [
|
|
233
59
|
{
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
"cognito-identity:*"
|
|
244
|
-
],
|
|
245
|
-
Resource: "*"
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
Effect: "Allow",
|
|
249
|
-
Action: ["execute-api:Invoke"],
|
|
250
|
-
Resource: {
|
|
251
|
-
"Fn::Sub": [
|
|
252
|
-
"arn:aws:execute-api:${Region}:${AccountId}:${APIID}/${StageName}/${HTTPVerb}/api/*",
|
|
253
|
-
{
|
|
254
|
-
Region: {
|
|
255
|
-
Ref: "AWS::Region"
|
|
256
|
-
},
|
|
257
|
-
AccountId: {
|
|
258
|
-
Ref: "AWS::AccountId"
|
|
259
|
-
},
|
|
260
|
-
APIID: apiGatewayRESTAPIId,
|
|
261
|
-
StageName: apiStageName,
|
|
262
|
-
HTTPVerb: "*"
|
|
263
|
-
}
|
|
264
|
-
]
|
|
265
|
-
}
|
|
60
|
+
Effect: "Allow",
|
|
61
|
+
Principal: {
|
|
62
|
+
Federated: "cognito-identity.amazonaws.com"
|
|
63
|
+
},
|
|
64
|
+
Action: ["sts:AssumeRoleWithWebIdentity"],
|
|
65
|
+
Condition: {
|
|
66
|
+
StringEquals: {
|
|
67
|
+
"cognito-identity.amazonaws.com:aud": {
|
|
68
|
+
Ref: resolvedIds.identityPool
|
|
266
69
|
}
|
|
267
|
-
|
|
70
|
+
},
|
|
71
|
+
"ForAnyValue:StringLike": {
|
|
72
|
+
"cognito-identity.amazonaws.com:amr": "authenticated"
|
|
73
|
+
}
|
|
268
74
|
}
|
|
269
75
|
}
|
|
270
76
|
]
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
77
|
+
},
|
|
78
|
+
Policies: [
|
|
79
|
+
{
|
|
80
|
+
PolicyName: "CognitoAuthorizedPolicy",
|
|
81
|
+
PolicyDocument: {
|
|
82
|
+
Version: "2012-10-17",
|
|
83
|
+
Statement: [
|
|
84
|
+
{
|
|
85
|
+
Effect: "Allow",
|
|
86
|
+
Action: [
|
|
87
|
+
"mobileanalytics:PutEvents",
|
|
88
|
+
"cognito-sync:*",
|
|
89
|
+
"cognito-identity:*"
|
|
90
|
+
],
|
|
91
|
+
Resource: "*"
|
|
285
92
|
},
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
93
|
+
{
|
|
94
|
+
Effect: "Allow",
|
|
95
|
+
Action: ["execute-api:Invoke"],
|
|
96
|
+
Resource: {
|
|
97
|
+
"Fn::Sub": [
|
|
98
|
+
"arn:aws:execute-api:${Region}:${AccountId}:${APIID}/${StageName}/${HTTPVerb}/api/*",
|
|
99
|
+
{
|
|
100
|
+
Region: {
|
|
101
|
+
Ref: "AWS::Region"
|
|
102
|
+
},
|
|
103
|
+
AccountId: {
|
|
104
|
+
Ref: "AWS::AccountId"
|
|
105
|
+
},
|
|
106
|
+
APIID: {
|
|
107
|
+
Ref: apiCloudFunctionGatewayId
|
|
108
|
+
},
|
|
109
|
+
StageName: apiStageName,
|
|
110
|
+
HTTPVerb: "*"
|
|
111
|
+
}
|
|
112
|
+
]
|
|
295
113
|
}
|
|
296
114
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
[resolvedIds.unauthRole]: {
|
|
122
|
+
Type: "AWS::IAM::Role",
|
|
123
|
+
Properties: {
|
|
124
|
+
RoleName: unauthRoleName,
|
|
125
|
+
Path: "/",
|
|
126
|
+
AssumeRolePolicyDocument: {
|
|
127
|
+
Version: "2012-10-17",
|
|
128
|
+
Statement: [
|
|
301
129
|
{
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
"cognito-identity:*"
|
|
312
|
-
],
|
|
313
|
-
Resource: "*"
|
|
130
|
+
Effect: "Allow",
|
|
131
|
+
Principal: {
|
|
132
|
+
Federated: "cognito-identity.amazonaws.com"
|
|
133
|
+
},
|
|
134
|
+
Action: ["sts:AssumeRoleWithWebIdentity"],
|
|
135
|
+
Condition: {
|
|
136
|
+
StringEquals: {
|
|
137
|
+
"cognito-identity.amazonaws.com:aud": {
|
|
138
|
+
Ref: resolvedIds.identityPool
|
|
314
139
|
}
|
|
315
|
-
|
|
140
|
+
},
|
|
141
|
+
"ForAnyValue:StringLike": {
|
|
142
|
+
"cognito-identity.amazonaws.com:amr": "unauthenticated"
|
|
143
|
+
}
|
|
316
144
|
}
|
|
317
145
|
}
|
|
318
146
|
]
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
Properties: {
|
|
327
|
-
UserPoolName: {
|
|
328
|
-
"Fn::Sub": [`\${AWS::StackName}${id}`, {}]
|
|
329
|
-
},
|
|
330
|
-
AccountRecoverySetting: {
|
|
331
|
-
RecoveryMechanisms: [
|
|
147
|
+
},
|
|
148
|
+
Policies: [
|
|
149
|
+
{
|
|
150
|
+
PolicyName: "CognitoUnauthorizedPolicy",
|
|
151
|
+
PolicyDocument: {
|
|
152
|
+
Version: "2012-10-17",
|
|
153
|
+
Statement: [
|
|
332
154
|
{
|
|
333
|
-
|
|
334
|
-
|
|
155
|
+
Effect: "Allow",
|
|
156
|
+
Action: [
|
|
157
|
+
"mobileanalytics:PutEvents",
|
|
158
|
+
"cognito-sync:*",
|
|
159
|
+
"cognito-identity:*"
|
|
160
|
+
],
|
|
161
|
+
Resource: "*"
|
|
335
162
|
}
|
|
336
163
|
]
|
|
337
|
-
},
|
|
338
|
-
AdminCreateUserConfig: {
|
|
339
|
-
AllowAdminCreateUserOnly: false,
|
|
340
|
-
UnusedAccountValidityDays: 365
|
|
341
|
-
},
|
|
342
|
-
AutoVerifiedAttributes: ["email"],
|
|
343
|
-
AliasAttributes: ["phone_number", "email", "preferred_username"],
|
|
344
|
-
Schema: [
|
|
345
|
-
{
|
|
346
|
-
Name: "email",
|
|
347
|
-
Required: true,
|
|
348
|
-
Mutable: true
|
|
349
|
-
},
|
|
350
|
-
{
|
|
351
|
-
Name: "given_name",
|
|
352
|
-
Required: true,
|
|
353
|
-
Mutable: true
|
|
354
|
-
},
|
|
355
|
-
{
|
|
356
|
-
Name: "family_name",
|
|
357
|
-
Required: true,
|
|
358
|
-
Mutable: true
|
|
359
|
-
},
|
|
360
|
-
{
|
|
361
|
-
Name: "phone_number",
|
|
362
|
-
Required: true,
|
|
363
|
-
Mutable: true
|
|
364
|
-
}
|
|
365
|
-
],
|
|
366
|
-
DeviceConfiguration: {
|
|
367
|
-
ChallengeRequiredOnNewDevice: true,
|
|
368
|
-
DeviceOnlyRememberedOnUserPrompt: false
|
|
369
|
-
},
|
|
370
|
-
UsernameConfiguration: {
|
|
371
|
-
CaseSensitive: false
|
|
372
164
|
}
|
|
373
165
|
}
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const userPoolDomainConfig = config.enableUserPoolDomain === false ? {} : {
|
|
171
|
+
[resolvedIds.baseDomainRecord]: {
|
|
172
|
+
Type: "AWS::Route53::RecordSet",
|
|
173
|
+
DeletionPolicy: "Delete",
|
|
174
|
+
Properties: {
|
|
175
|
+
HostedZoneId: {
|
|
176
|
+
Ref: config.hostedZoneIdParameterName
|
|
374
177
|
},
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
HostedZoneId: "Z2FDTNDATAQYW2",
|
|
384
|
-
DNSName: baseDomainRecordAliasTargetDNSName
|
|
385
|
-
}
|
|
178
|
+
Type: "A",
|
|
179
|
+
Name: {
|
|
180
|
+
Ref: config.domainNameParameterName
|
|
181
|
+
},
|
|
182
|
+
AliasTarget: {
|
|
183
|
+
HostedZoneId: "Z2FDTNDATAQYW2",
|
|
184
|
+
DNSName: {
|
|
185
|
+
"Fn::GetAtt": [config.mainCDNCloudFrontId, "DomainName"]
|
|
386
186
|
}
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
DNSName: {
|
|
405
|
-
"Fn::GetAtt": [`${id}Domain`, "CloudFrontDistribution"]
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
[resolvedIds.domainRecord]: {
|
|
191
|
+
Type: "AWS::Route53::RecordSet",
|
|
192
|
+
DeletionPolicy: "Delete",
|
|
193
|
+
Properties: {
|
|
194
|
+
HostedZoneId: {
|
|
195
|
+
Ref: config.hostedZoneIdParameterName
|
|
196
|
+
},
|
|
197
|
+
Type: "A",
|
|
198
|
+
Name: {
|
|
199
|
+
"Fn::Sub": [
|
|
200
|
+
"auth.${BaseDomainName}",
|
|
201
|
+
{
|
|
202
|
+
BaseDomainName: {
|
|
203
|
+
Ref: config.domainNameParameterName
|
|
406
204
|
}
|
|
407
205
|
}
|
|
206
|
+
]
|
|
207
|
+
},
|
|
208
|
+
AliasTarget: {
|
|
209
|
+
HostedZoneId: "Z2FDTNDATAQYW2",
|
|
210
|
+
DNSName: {
|
|
211
|
+
"Fn::GetAtt": [resolvedIds.domain, "CloudFrontDistribution"]
|
|
408
212
|
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
[resolvedIds.domain]: {
|
|
217
|
+
Type: "AWS::Cognito::UserPoolDomain",
|
|
218
|
+
DependsOn: resolvedIds.baseDomainRecord,
|
|
219
|
+
Properties: {
|
|
220
|
+
Domain: {
|
|
221
|
+
"Fn::Sub": [
|
|
222
|
+
"auth.${BaseDomainName}",
|
|
223
|
+
{
|
|
224
|
+
BaseDomainName: {
|
|
225
|
+
Ref: config.domainNameParameterName
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
]
|
|
409
229
|
},
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
230
|
+
UserPoolId: {
|
|
231
|
+
Ref: resolvedIds.userPool
|
|
232
|
+
},
|
|
233
|
+
CustomDomainConfig: {
|
|
234
|
+
CertificateArn: {
|
|
235
|
+
Ref: config.sslCertificateId
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
const callbackUrls = config.enableUserPoolDomain === false ? void 0 : config.callbackUrls;
|
|
242
|
+
const logoutUrls = config.enableUserPoolDomain === false ? void 0 : config.logoutUrls;
|
|
243
|
+
return new SimpleCFT().patch({
|
|
244
|
+
Resources: {
|
|
245
|
+
[resolvedIds.userPool]: {
|
|
246
|
+
Type: "AWS::Cognito::UserPool",
|
|
247
|
+
Properties: {
|
|
248
|
+
UserPoolName: {
|
|
249
|
+
"Fn::Sub": [`\${AWS::StackName}${userManagementId}`, {}]
|
|
250
|
+
},
|
|
251
|
+
AccountRecoverySetting: {
|
|
252
|
+
RecoveryMechanisms: [
|
|
253
|
+
{
|
|
254
|
+
Name: "verified_email",
|
|
255
|
+
Priority: 1
|
|
256
|
+
}
|
|
257
|
+
]
|
|
258
|
+
},
|
|
259
|
+
AdminCreateUserConfig: {
|
|
260
|
+
AllowAdminCreateUserOnly: false,
|
|
261
|
+
UnusedAccountValidityDays: 365
|
|
262
|
+
},
|
|
263
|
+
AutoVerifiedAttributes: ["email"],
|
|
264
|
+
AliasAttributes: ["phone_number", "email", "preferred_username"],
|
|
265
|
+
Schema: [
|
|
266
|
+
{
|
|
267
|
+
Name: "email",
|
|
268
|
+
Required: true,
|
|
269
|
+
Mutable: true
|
|
421
270
|
},
|
|
422
|
-
|
|
423
|
-
|
|
271
|
+
{
|
|
272
|
+
Name: "given_name",
|
|
273
|
+
Required: true,
|
|
274
|
+
Mutable: true
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
Name: "family_name",
|
|
278
|
+
Required: true,
|
|
279
|
+
Mutable: true
|
|
424
280
|
},
|
|
425
|
-
|
|
426
|
-
|
|
281
|
+
{
|
|
282
|
+
Name: "phone_number",
|
|
283
|
+
Required: true,
|
|
284
|
+
Mutable: true
|
|
427
285
|
}
|
|
286
|
+
],
|
|
287
|
+
DeviceConfiguration: {
|
|
288
|
+
ChallengeRequiredOnNewDevice: true,
|
|
289
|
+
DeviceOnlyRememberedOnUserPrompt: false
|
|
290
|
+
},
|
|
291
|
+
UsernameConfiguration: {
|
|
292
|
+
CaseSensitive: false
|
|
428
293
|
}
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
[resolvedIds.userPoolClient]: {
|
|
297
|
+
Type: "AWS::Cognito::UserPoolClient",
|
|
298
|
+
Properties: {
|
|
299
|
+
ClientName: {
|
|
300
|
+
"Fn::Sub": [`\${AWS::StackName}${userManagementId}Client`, {}]
|
|
301
|
+
},
|
|
302
|
+
UserPoolId: {
|
|
303
|
+
Ref: resolvedIds.userPool
|
|
304
|
+
},
|
|
305
|
+
...isUserPoolDomainEnabled ? {
|
|
439
306
|
AllowedOAuthFlowsUserPoolClient: true,
|
|
440
307
|
AllowedOAuthFlows: ["code", "implicit"],
|
|
441
308
|
AllowedOAuthScopes: [
|
|
@@ -445,178 +312,54 @@ var addUserManagement = createResourcePack(
|
|
|
445
312
|
"profile",
|
|
446
313
|
"aws.cognito.signin.user.admin"
|
|
447
314
|
],
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
{
|
|
464
|
-
|
|
465
|
-
Ref: `${id}Client`
|
|
466
|
-
},
|
|
467
|
-
ProviderName: {
|
|
468
|
-
"Fn::GetAtt": [id, "ProviderName"]
|
|
469
|
-
},
|
|
470
|
-
ServerSideTokenCheck: true
|
|
471
|
-
}
|
|
315
|
+
SupportedIdentityProviders: supportedIdentityProviders
|
|
316
|
+
} : {
|
|
317
|
+
AllowedOAuthFlowsUserPoolClient: false
|
|
318
|
+
},
|
|
319
|
+
EnableTokenRevocation: true,
|
|
320
|
+
PreventUserExistenceErrors: "ENABLED",
|
|
321
|
+
...callbackUrls && callbackUrls.length > 0 ? { CallbackURLs: callbackUrls } : {},
|
|
322
|
+
...logoutUrls && logoutUrls.length > 0 ? { LogoutURLs: logoutUrls } : {}
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
[resolvedIds.identityPool]: {
|
|
326
|
+
Type: "AWS::Cognito::IdentityPool",
|
|
327
|
+
Properties: {
|
|
328
|
+
IdentityPoolName: {
|
|
329
|
+
"Fn::Sub": [
|
|
330
|
+
`\${AWS::StackName}${userManagementId}IdentityPool`,
|
|
331
|
+
{}
|
|
472
332
|
]
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
}
|
|
491
|
-
/**
|
|
492
|
-
* Apply a pack with configuration to the stack template.
|
|
493
|
-
* @see {@link IaC} for an example.
|
|
494
|
-
* */
|
|
495
|
-
applyPack = (pack, params) => {
|
|
496
|
-
this.template = pack(params, this.template);
|
|
497
|
-
return this;
|
|
498
|
-
};
|
|
499
|
-
/**
|
|
500
|
-
* Apply a patch to the stack template.
|
|
501
|
-
*
|
|
502
|
-
* @param patch - Template patch to merge.
|
|
503
|
-
* */
|
|
504
|
-
patch = (patch) => {
|
|
505
|
-
this.template = patchTemplate(patch, this.template);
|
|
506
|
-
return this;
|
|
507
|
-
};
|
|
508
|
-
/**
|
|
509
|
-
* Add a stack parameter including its descriptive info and an optional parameter group.
|
|
510
|
-
*
|
|
511
|
-
* @param parameter - Parameter definition and metadata.
|
|
512
|
-
* */
|
|
513
|
-
addParameter = (parameter) => {
|
|
514
|
-
this.template = addParameter(parameter, this.template);
|
|
515
|
-
return this;
|
|
516
|
-
};
|
|
517
|
-
/**
|
|
518
|
-
* Add a group of stack parameters including their descriptive info and an optional parameter group.
|
|
519
|
-
*
|
|
520
|
-
* @param group - Parameter group definition.
|
|
521
|
-
* */
|
|
522
|
-
addParameterGroup = ({ Label: Group, Parameters }) => {
|
|
523
|
-
const parameterIds = Object.keys(Parameters);
|
|
524
|
-
const parameterList = parameterIds.map((ParameterId) => {
|
|
525
|
-
const { Label, ...Parameter } = Parameters[ParameterId];
|
|
526
|
-
return {
|
|
527
|
-
Group,
|
|
528
|
-
ParameterId,
|
|
529
|
-
Label,
|
|
530
|
-
Parameter
|
|
531
|
-
};
|
|
532
|
-
});
|
|
533
|
-
this.template = addParameters(parameterList, this.template);
|
|
534
|
-
return this;
|
|
535
|
-
};
|
|
536
|
-
/**
|
|
537
|
-
* Use a modification to dynamically apply various changes at once.
|
|
538
|
-
*
|
|
539
|
-
* @param modification - Modification callback to apply.
|
|
540
|
-
* */
|
|
541
|
-
modify = (modification) => {
|
|
542
|
-
modification(this);
|
|
543
|
-
return this;
|
|
544
|
-
};
|
|
545
|
-
/**
|
|
546
|
-
* Convert the stack template to a string.
|
|
547
|
-
*
|
|
548
|
-
* @returns JSON string representation of the template.
|
|
549
|
-
* */
|
|
550
|
-
toString = () => JSON.stringify(this.template, null, 2);
|
|
551
|
-
/**
|
|
552
|
-
* Convert the stack template to a JSON object.
|
|
553
|
-
*
|
|
554
|
-
* @returns Template JSON object.
|
|
555
|
-
* */
|
|
556
|
-
toJSON = () => this.template;
|
|
557
|
-
/**
|
|
558
|
-
* Convert the stack template to a YAML string.
|
|
559
|
-
*
|
|
560
|
-
* @returns YAML string representation of the template.
|
|
561
|
-
* */
|
|
562
|
-
toYAML = () => YAML.stringify(this.template, {
|
|
563
|
-
aliasDuplicateObjects: false
|
|
564
|
-
});
|
|
565
|
-
};
|
|
566
|
-
|
|
567
|
-
// src/iac/packs/auth.ts
|
|
568
|
-
var addAuth = createResourcePack(
|
|
569
|
-
({
|
|
570
|
-
userManagementId,
|
|
571
|
-
authRoleName,
|
|
572
|
-
unauthRoleName,
|
|
573
|
-
hostedZoneIdParameterName,
|
|
574
|
-
domainNameParameterName,
|
|
575
|
-
sslCertificateId,
|
|
576
|
-
callbackUrls,
|
|
577
|
-
logoutUrls,
|
|
578
|
-
mainCDNCloudFrontId,
|
|
579
|
-
apiCloudFunctionGatewayId,
|
|
580
|
-
apiStageName,
|
|
581
|
-
adminGroupId,
|
|
582
|
-
userManagementAdminGroupName
|
|
583
|
-
}) => new SimpleCFT().applyPack(addUserManagement, {
|
|
584
|
-
id: userManagementId,
|
|
585
|
-
authRoleName,
|
|
586
|
-
unauthRoleName,
|
|
587
|
-
domainName: {
|
|
588
|
-
Ref: domainNameParameterName
|
|
589
|
-
},
|
|
590
|
-
hostedZoneId: {
|
|
591
|
-
Ref: hostedZoneIdParameterName
|
|
592
|
-
},
|
|
593
|
-
sslCertificateArn: {
|
|
594
|
-
Ref: sslCertificateId
|
|
595
|
-
},
|
|
596
|
-
callbackUrls,
|
|
597
|
-
logoutUrls,
|
|
598
|
-
baseDomainRecordAliasTargetDNSName: {
|
|
599
|
-
"Fn::GetAtt": [mainCDNCloudFrontId, "DomainName"]
|
|
600
|
-
},
|
|
601
|
-
apiGatewayRESTAPIId: {
|
|
602
|
-
Ref: apiCloudFunctionGatewayId
|
|
603
|
-
},
|
|
604
|
-
apiStageName
|
|
605
|
-
}).patch({
|
|
606
|
-
Resources: {
|
|
333
|
+
},
|
|
334
|
+
AllowUnauthenticatedIdentities: false,
|
|
335
|
+
CognitoIdentityProviders: [
|
|
336
|
+
{
|
|
337
|
+
ClientId: {
|
|
338
|
+
Ref: resolvedIds.userPoolClient
|
|
339
|
+
},
|
|
340
|
+
ProviderName: {
|
|
341
|
+
"Fn::GetAtt": [resolvedIds.userPool, "ProviderName"]
|
|
342
|
+
},
|
|
343
|
+
ServerSideTokenCheck: true
|
|
344
|
+
}
|
|
345
|
+
]
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
...userPoolDomainConfig,
|
|
349
|
+
...apiRoleConfig,
|
|
607
350
|
[adminGroupId]: {
|
|
608
351
|
Type: "AWS::Cognito::UserPoolGroup",
|
|
609
352
|
Properties: {
|
|
610
353
|
GroupName: userManagementAdminGroupName,
|
|
611
354
|
UserPoolId: {
|
|
612
|
-
Ref:
|
|
355
|
+
Ref: resolvedIds.userPool
|
|
613
356
|
},
|
|
614
357
|
Description: "Application admin group."
|
|
615
358
|
}
|
|
616
359
|
}
|
|
617
360
|
}
|
|
618
|
-
}).template
|
|
619
|
-
);
|
|
361
|
+
}).template;
|
|
362
|
+
});
|
|
620
363
|
|
|
621
364
|
// src/iac/packs/build.ts
|
|
622
365
|
var DEFAULT_BUILD_PIPELINE_REPO_PROVIDER = "GitHub";
|
|
@@ -1035,7 +778,8 @@ var addCloudFunction = createResourcePack(
|
|
|
1035
778
|
]
|
|
1036
779
|
}
|
|
1037
780
|
}
|
|
1038
|
-
]
|
|
781
|
+
],
|
|
782
|
+
memorySize = 128
|
|
1039
783
|
}) => {
|
|
1040
784
|
return {
|
|
1041
785
|
Resources: {
|
|
@@ -1070,7 +814,8 @@ var addCloudFunction = createResourcePack(
|
|
|
1070
814
|
Role: {
|
|
1071
815
|
"Fn::GetAtt": [`${id}Role`, "Arn"]
|
|
1072
816
|
},
|
|
1073
|
-
Runtime: runtime
|
|
817
|
+
Runtime: runtime,
|
|
818
|
+
MemorySize: memorySize
|
|
1074
819
|
}
|
|
1075
820
|
}
|
|
1076
821
|
}
|
|
@@ -1205,6 +950,31 @@ var addSecureFileStorage = createResourcePack(
|
|
|
1205
950
|
);
|
|
1206
951
|
|
|
1207
952
|
// src/iac/packs/gateway.ts
|
|
953
|
+
var canonicalizeHashableValue = (value) => {
|
|
954
|
+
if (Array.isArray(value)) {
|
|
955
|
+
return value.map((item) => canonicalizeHashableValue(item));
|
|
956
|
+
}
|
|
957
|
+
if (value && typeof value === "object") {
|
|
958
|
+
const output = {};
|
|
959
|
+
Object.keys(value).sort().forEach((key) => {
|
|
960
|
+
output[key] = canonicalizeHashableValue(
|
|
961
|
+
value[key]
|
|
962
|
+
);
|
|
963
|
+
});
|
|
964
|
+
return output;
|
|
965
|
+
}
|
|
966
|
+
return value;
|
|
967
|
+
};
|
|
968
|
+
var getDeterministicHash = (value) => {
|
|
969
|
+
const canonical = JSON.stringify(canonicalizeHashableValue(value));
|
|
970
|
+
let hash = 2166136261;
|
|
971
|
+
for (let i = 0; i < canonical.length; i += 1) {
|
|
972
|
+
hash ^= canonical.charCodeAt(i);
|
|
973
|
+
hash = Math.imul(hash, 16777619);
|
|
974
|
+
hash >>>= 0;
|
|
975
|
+
}
|
|
976
|
+
return hash.toString(16).toUpperCase().padStart(8, "0");
|
|
977
|
+
};
|
|
1208
978
|
var DEFAULT_AUTH_TYPE = "COGNITO_USER_POOLS";
|
|
1209
979
|
var addGateway = createResourcePack(
|
|
1210
980
|
({
|
|
@@ -1227,8 +997,29 @@ var addGateway = createResourcePack(
|
|
|
1227
997
|
scopes: authScopes = ["phone", "email", "openid", "profile"],
|
|
1228
998
|
type: authType = "COGNITO_USER_POOLS",
|
|
1229
999
|
providerARNs,
|
|
1230
|
-
identitySource = "method.request.header.
|
|
1000
|
+
identitySource = "method.request.header.Authorization"
|
|
1231
1001
|
} = !!authorizer && typeof authorizer === "object" ? authorizer : {};
|
|
1002
|
+
const cloudFunctionIntegration = {
|
|
1003
|
+
Type: "AWS_PROXY",
|
|
1004
|
+
IntegrationHttpMethod: "POST",
|
|
1005
|
+
Uri: cloudFunctionUri
|
|
1006
|
+
};
|
|
1007
|
+
const gatewayResponseParameters = {
|
|
1008
|
+
"gatewayresponse.header.Access-Control-Allow-Origin": "method.request.header.origin",
|
|
1009
|
+
"gatewayresponse.header.Access-Control-Allow-Credentials": "'true'",
|
|
1010
|
+
"gatewayresponse.header.Access-Control-Allow-Headers": "'*'"
|
|
1011
|
+
};
|
|
1012
|
+
const cloudFunctionPermissionSourceArn = {
|
|
1013
|
+
"Fn::Sub": [
|
|
1014
|
+
"arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*/*",
|
|
1015
|
+
{
|
|
1016
|
+
__Stage__: stageName,
|
|
1017
|
+
__ApiId__: {
|
|
1018
|
+
Ref: id
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
]
|
|
1022
|
+
};
|
|
1232
1023
|
const authorizerId = `${id}CustomAuthorizer`;
|
|
1233
1024
|
const authProps = !!authorizer ? {
|
|
1234
1025
|
AuthorizationScopes: authScopes,
|
|
@@ -1239,7 +1030,33 @@ var addGateway = createResourcePack(
|
|
|
1239
1030
|
} : {
|
|
1240
1031
|
AuthorizationType: "NONE"
|
|
1241
1032
|
};
|
|
1242
|
-
const
|
|
1033
|
+
const gatewayDeploymentFingerprint = {
|
|
1034
|
+
restApiEndpointTypes: ["EDGE"],
|
|
1035
|
+
proxyPathPart: "{proxy+}",
|
|
1036
|
+
anyMethod: {
|
|
1037
|
+
...authProps,
|
|
1038
|
+
HttpMethod: "ANY",
|
|
1039
|
+
Integration: cloudFunctionIntegration
|
|
1040
|
+
},
|
|
1041
|
+
optionsMethod: {
|
|
1042
|
+
AuthorizationType: "NONE",
|
|
1043
|
+
HttpMethod: "OPTIONS",
|
|
1044
|
+
Integration: cloudFunctionIntegration
|
|
1045
|
+
},
|
|
1046
|
+
gatewayResponseDefault4XX: {
|
|
1047
|
+
ResponseParameters: gatewayResponseParameters,
|
|
1048
|
+
ResponseType: "DEFAULT_4XX"
|
|
1049
|
+
},
|
|
1050
|
+
stageName,
|
|
1051
|
+
cloudFunctionPermissionSourceArn,
|
|
1052
|
+
authorizer: !!authorizer ? {
|
|
1053
|
+
IdentitySource: identitySource,
|
|
1054
|
+
ProviderARNs: providerARNs,
|
|
1055
|
+
Type: "COGNITO_USER_POOLS"
|
|
1056
|
+
} : null
|
|
1057
|
+
};
|
|
1058
|
+
const deploymentHash = getDeterministicHash(gatewayDeploymentFingerprint);
|
|
1059
|
+
const fullDeploymentId = `${id}GatewayRESTAPIDeployment${deploymentHash}${deploymentSuffix}`;
|
|
1243
1060
|
return new SimpleCFT().patch({
|
|
1244
1061
|
Resources: {
|
|
1245
1062
|
// REST API
|
|
@@ -1280,9 +1097,7 @@ var addGateway = createResourcePack(
|
|
|
1280
1097
|
Ref: id
|
|
1281
1098
|
},
|
|
1282
1099
|
Integration: {
|
|
1283
|
-
|
|
1284
|
-
IntegrationHttpMethod: "POST",
|
|
1285
|
-
Uri: cloudFunctionUri
|
|
1100
|
+
...cloudFunctionIntegration
|
|
1286
1101
|
}
|
|
1287
1102
|
}
|
|
1288
1103
|
},
|
|
@@ -1299,9 +1114,7 @@ var addGateway = createResourcePack(
|
|
|
1299
1114
|
Ref: id
|
|
1300
1115
|
},
|
|
1301
1116
|
Integration: {
|
|
1302
|
-
|
|
1303
|
-
IntegrationHttpMethod: "POST",
|
|
1304
|
-
Uri: cloudFunctionUri
|
|
1117
|
+
...cloudFunctionIntegration
|
|
1305
1118
|
}
|
|
1306
1119
|
}
|
|
1307
1120
|
}
|
|
@@ -1322,9 +1135,7 @@ var addGateway = createResourcePack(
|
|
|
1322
1135
|
Ref: id
|
|
1323
1136
|
},
|
|
1324
1137
|
Integration: {
|
|
1325
|
-
|
|
1326
|
-
IntegrationHttpMethod: "POST",
|
|
1327
|
-
Uri: cloudFunctionUri
|
|
1138
|
+
...cloudFunctionIntegration
|
|
1328
1139
|
}
|
|
1329
1140
|
}
|
|
1330
1141
|
},
|
|
@@ -1341,21 +1152,15 @@ var addGateway = createResourcePack(
|
|
|
1341
1152
|
Ref: id
|
|
1342
1153
|
},
|
|
1343
1154
|
Integration: {
|
|
1344
|
-
|
|
1345
|
-
IntegrationHttpMethod: "POST",
|
|
1346
|
-
Uri: cloudFunctionUri
|
|
1155
|
+
...cloudFunctionIntegration
|
|
1347
1156
|
}
|
|
1348
1157
|
}
|
|
1349
1158
|
},
|
|
1350
1159
|
[`${id}GatewayResponseDefault4XX`]: {
|
|
1351
1160
|
Type: "AWS::ApiGateway::GatewayResponse",
|
|
1352
1161
|
Properties: {
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
"gatewayresponse.header.Access-Control-Allow-Origin": "method.request.header.origin",
|
|
1356
|
-
"gatewayresponse.header.Access-Control-Allow-Credentials": "'true'",
|
|
1357
|
-
"gatewayresponse.header.Access-Control-Allow-Headers": "'*'"
|
|
1358
|
-
},
|
|
1162
|
+
// Not authorized, so just allow the current origin by mapping it into the header.
|
|
1163
|
+
ResponseParameters: gatewayResponseParameters,
|
|
1359
1164
|
ResponseType: "DEFAULT_4XX",
|
|
1360
1165
|
RestApiId: {
|
|
1361
1166
|
Ref: id
|
|
@@ -1511,15 +1316,7 @@ var addGateway = createResourcePack(
|
|
|
1511
1316
|
"Fn::GetAtt": [cloudFunctionId, "Arn"]
|
|
1512
1317
|
},
|
|
1513
1318
|
SourceArn: {
|
|
1514
|
-
|
|
1515
|
-
"arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*/*",
|
|
1516
|
-
{
|
|
1517
|
-
__Stage__: stageName,
|
|
1518
|
-
__ApiId__: {
|
|
1519
|
-
Ref: id
|
|
1520
|
-
}
|
|
1521
|
-
}
|
|
1522
|
-
]
|
|
1319
|
+
...cloudFunctionPermissionSourceArn
|
|
1523
1320
|
}
|
|
1524
1321
|
}
|
|
1525
1322
|
}
|