@ttoss/cloud-auth 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +6 -6
- package/.turbo/turbo-test.log +28 -0
- package/CHANGELOG.md +10 -0
- package/README.md +19 -0
- package/babel.config.js +3 -0
- package/coverage/clover.xml +207 -0
- package/coverage/coverage-final.json +4 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/config.ts.html +88 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +146 -0
- package/coverage/lcov-report/index.ts.html +91 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/template.ts.html +652 -0
- package/coverage/lcov.info +235 -0
- package/dist/esm/index.js +59 -32
- package/dist/index.d.ts +33 -104
- package/dist/index.js +59 -32
- package/jest.config.ts +5 -0
- package/package.json +9 -5
- package/src/template.ts +107 -46
- package/tests/unit/template.test.ts +73 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
TN:
|
|
2
|
+
SF:src/config.ts
|
|
3
|
+
FNF:0
|
|
4
|
+
FNH:0
|
|
5
|
+
DA:1,1
|
|
6
|
+
LF:1
|
|
7
|
+
LH:1
|
|
8
|
+
BRF:0
|
|
9
|
+
BRH:0
|
|
10
|
+
end_of_record
|
|
11
|
+
TN:
|
|
12
|
+
SF:src/index.ts
|
|
13
|
+
FNF:0
|
|
14
|
+
FNH:0
|
|
15
|
+
DA:1,1
|
|
16
|
+
DA:2,1
|
|
17
|
+
LF:2
|
|
18
|
+
LH:2
|
|
19
|
+
BRDA:1,0,0,2
|
|
20
|
+
BRDA:1,1,0,1
|
|
21
|
+
BRDA:1,2,0,0
|
|
22
|
+
BRDA:1,3,0,1
|
|
23
|
+
BRDA:1,4,0,0
|
|
24
|
+
BRDA:1,5,0,0
|
|
25
|
+
BRDA:1,6,0,1
|
|
26
|
+
BRF:7
|
|
27
|
+
BRH:4
|
|
28
|
+
end_of_record
|
|
29
|
+
TN:
|
|
30
|
+
SF:src/template.ts
|
|
31
|
+
FN:16,createAuthTemplate
|
|
32
|
+
FNF:1
|
|
33
|
+
FNH:1
|
|
34
|
+
FNDA:11,createAuthTemplate
|
|
35
|
+
DA:1,1
|
|
36
|
+
DA:2,1
|
|
37
|
+
DA:3,1
|
|
38
|
+
DA:4,1
|
|
39
|
+
DA:5,1
|
|
40
|
+
DA:6,1
|
|
41
|
+
DA:7,1
|
|
42
|
+
DA:8,1
|
|
43
|
+
DA:9,1
|
|
44
|
+
DA:10,1
|
|
45
|
+
DA:11,1
|
|
46
|
+
DA:12,1
|
|
47
|
+
DA:13,1
|
|
48
|
+
DA:14,1
|
|
49
|
+
DA:15,1
|
|
50
|
+
DA:16,1
|
|
51
|
+
DA:17,11
|
|
52
|
+
DA:18,11
|
|
53
|
+
DA:19,11
|
|
54
|
+
DA:20,11
|
|
55
|
+
DA:21,11
|
|
56
|
+
DA:22,11
|
|
57
|
+
DA:23,11
|
|
58
|
+
DA:24,11
|
|
59
|
+
DA:25,11
|
|
60
|
+
DA:26,11
|
|
61
|
+
DA:27,11
|
|
62
|
+
DA:28,11
|
|
63
|
+
DA:29,11
|
|
64
|
+
DA:30,11
|
|
65
|
+
DA:31,11
|
|
66
|
+
DA:32,11
|
|
67
|
+
DA:33,11
|
|
68
|
+
DA:34,11
|
|
69
|
+
DA:35,11
|
|
70
|
+
DA:36,11
|
|
71
|
+
DA:37,11
|
|
72
|
+
DA:38,11
|
|
73
|
+
DA:39,11
|
|
74
|
+
DA:40,11
|
|
75
|
+
DA:41,11
|
|
76
|
+
DA:42,11
|
|
77
|
+
DA:43,11
|
|
78
|
+
DA:44,11
|
|
79
|
+
DA:45,11
|
|
80
|
+
DA:46,11
|
|
81
|
+
DA:47,11
|
|
82
|
+
DA:48,11
|
|
83
|
+
DA:49,8
|
|
84
|
+
DA:50,11
|
|
85
|
+
DA:51,11
|
|
86
|
+
DA:52,11
|
|
87
|
+
DA:53,11
|
|
88
|
+
DA:54,11
|
|
89
|
+
DA:55,11
|
|
90
|
+
DA:56,11
|
|
91
|
+
DA:57,11
|
|
92
|
+
DA:58,11
|
|
93
|
+
DA:59,11
|
|
94
|
+
DA:60,11
|
|
95
|
+
DA:61,11
|
|
96
|
+
DA:62,11
|
|
97
|
+
DA:63,11
|
|
98
|
+
DA:64,11
|
|
99
|
+
DA:65,11
|
|
100
|
+
DA:66,11
|
|
101
|
+
DA:67,11
|
|
102
|
+
DA:68,11
|
|
103
|
+
DA:69,11
|
|
104
|
+
DA:70,11
|
|
105
|
+
DA:71,11
|
|
106
|
+
DA:72,11
|
|
107
|
+
DA:73,11
|
|
108
|
+
DA:74,11
|
|
109
|
+
DA:75,11
|
|
110
|
+
DA:76,11
|
|
111
|
+
DA:77,11
|
|
112
|
+
DA:78,11
|
|
113
|
+
DA:79,11
|
|
114
|
+
DA:80,11
|
|
115
|
+
DA:81,11
|
|
116
|
+
DA:82,11
|
|
117
|
+
DA:83,11
|
|
118
|
+
DA:84,11
|
|
119
|
+
DA:85,11
|
|
120
|
+
DA:86,11
|
|
121
|
+
DA:87,11
|
|
122
|
+
DA:88,11
|
|
123
|
+
DA:89,11
|
|
124
|
+
DA:90,11
|
|
125
|
+
DA:91,11
|
|
126
|
+
DA:92,11
|
|
127
|
+
DA:93,11
|
|
128
|
+
DA:94,11
|
|
129
|
+
DA:95,11
|
|
130
|
+
DA:96,11
|
|
131
|
+
DA:97,11
|
|
132
|
+
DA:98,11
|
|
133
|
+
DA:99,11
|
|
134
|
+
DA:100,11
|
|
135
|
+
DA:101,11
|
|
136
|
+
DA:102,11
|
|
137
|
+
DA:103,11
|
|
138
|
+
DA:104,11
|
|
139
|
+
DA:105,11
|
|
140
|
+
DA:106,11
|
|
141
|
+
DA:107,11
|
|
142
|
+
DA:108,11
|
|
143
|
+
DA:109,11
|
|
144
|
+
DA:110,11
|
|
145
|
+
DA:111,11
|
|
146
|
+
DA:112,11
|
|
147
|
+
DA:113,11
|
|
148
|
+
DA:114,11
|
|
149
|
+
DA:115,11
|
|
150
|
+
DA:116,11
|
|
151
|
+
DA:117,11
|
|
152
|
+
DA:118,11
|
|
153
|
+
DA:119,11
|
|
154
|
+
DA:120,11
|
|
155
|
+
DA:121,11
|
|
156
|
+
DA:122,11
|
|
157
|
+
DA:123,11
|
|
158
|
+
DA:124,11
|
|
159
|
+
DA:125,11
|
|
160
|
+
DA:126,11
|
|
161
|
+
DA:127,11
|
|
162
|
+
DA:128,10
|
|
163
|
+
DA:129,10
|
|
164
|
+
DA:130,10
|
|
165
|
+
DA:131,10
|
|
166
|
+
DA:132,10
|
|
167
|
+
DA:133,10
|
|
168
|
+
DA:134,10
|
|
169
|
+
DA:135,10
|
|
170
|
+
DA:136,10
|
|
171
|
+
DA:137,10
|
|
172
|
+
DA:138,10
|
|
173
|
+
DA:139,10
|
|
174
|
+
DA:140,10
|
|
175
|
+
DA:141,10
|
|
176
|
+
DA:142,10
|
|
177
|
+
DA:143,10
|
|
178
|
+
DA:144,10
|
|
179
|
+
DA:145,10
|
|
180
|
+
DA:146,10
|
|
181
|
+
DA:147,10
|
|
182
|
+
DA:148,10
|
|
183
|
+
DA:149,1
|
|
184
|
+
DA:150,1
|
|
185
|
+
DA:151,1
|
|
186
|
+
DA:152,1
|
|
187
|
+
DA:153,1
|
|
188
|
+
DA:154,1
|
|
189
|
+
DA:155,1
|
|
190
|
+
DA:156,1
|
|
191
|
+
DA:157,1
|
|
192
|
+
DA:158,1
|
|
193
|
+
DA:159,1
|
|
194
|
+
DA:160,1
|
|
195
|
+
DA:161,1
|
|
196
|
+
DA:162,10
|
|
197
|
+
DA:163,10
|
|
198
|
+
DA:164,0
|
|
199
|
+
DA:165,0
|
|
200
|
+
DA:166,10
|
|
201
|
+
DA:167,10
|
|
202
|
+
DA:168,10
|
|
203
|
+
DA:169,10
|
|
204
|
+
DA:170,10
|
|
205
|
+
DA:171,10
|
|
206
|
+
DA:172,10
|
|
207
|
+
DA:173,10
|
|
208
|
+
DA:174,10
|
|
209
|
+
DA:175,10
|
|
210
|
+
DA:176,10
|
|
211
|
+
DA:177,10
|
|
212
|
+
DA:178,10
|
|
213
|
+
DA:179,10
|
|
214
|
+
DA:180,10
|
|
215
|
+
DA:181,10
|
|
216
|
+
DA:182,11
|
|
217
|
+
DA:183,11
|
|
218
|
+
DA:184,11
|
|
219
|
+
DA:185,1
|
|
220
|
+
DA:186,1
|
|
221
|
+
DA:187,1
|
|
222
|
+
DA:188,1
|
|
223
|
+
DA:189,1
|
|
224
|
+
LF:189
|
|
225
|
+
LH:187
|
|
226
|
+
BRDA:16,0,0,11
|
|
227
|
+
BRDA:48,1,0,9
|
|
228
|
+
BRDA:49,2,0,8
|
|
229
|
+
BRDA:50,3,0,3
|
|
230
|
+
BRDA:127,4,0,10
|
|
231
|
+
BRDA:148,5,0,1
|
|
232
|
+
BRDA:163,6,0,0
|
|
233
|
+
BRF:7
|
|
234
|
+
BRH:6
|
|
235
|
+
end_of_record
|
package/dist/esm/index.js
CHANGED
|
@@ -7,13 +7,20 @@ var PASSWORD_MINIMUM_LENGTH = 8;
|
|
|
7
7
|
var CognitoUserPoolLogicalId = "CognitoUserPool";
|
|
8
8
|
var CognitoUserPoolClientLogicalId = "CognitoUserPoolClient";
|
|
9
9
|
var CognitoIdentityPoolLogicalId = "CognitoIdentityPool";
|
|
10
|
-
var createAuthTemplate = (
|
|
10
|
+
var createAuthTemplate = ({
|
|
11
|
+
autoVerifiedAttributes = ["email"],
|
|
12
|
+
identityPool = true,
|
|
13
|
+
roles,
|
|
14
|
+
schema
|
|
15
|
+
} = {}) => {
|
|
16
|
+
const AutoVerifiedAttributes = Array.isArray(autoVerifiedAttributes) && autoVerifiedAttributes.length > 0 ? autoVerifiedAttributes : void 0;
|
|
11
17
|
const template = {
|
|
18
|
+
AWSTemplateFormatVersion: "2010-09-09",
|
|
12
19
|
Resources: {
|
|
13
20
|
[CognitoUserPoolLogicalId]: {
|
|
14
21
|
Type: "AWS::Cognito::UserPool",
|
|
15
22
|
Properties: {
|
|
16
|
-
AutoVerifiedAttributes
|
|
23
|
+
AutoVerifiedAttributes,
|
|
17
24
|
Policies: {
|
|
18
25
|
PasswordPolicy: {
|
|
19
26
|
MinimumLength: PASSWORD_MINIMUM_LENGTH,
|
|
@@ -24,6 +31,7 @@ var createAuthTemplate = () => {
|
|
|
24
31
|
TemporaryPasswordValidityDays: 30
|
|
25
32
|
}
|
|
26
33
|
},
|
|
34
|
+
Schema: schema,
|
|
27
35
|
UsernameAttributes: ["email"],
|
|
28
36
|
UsernameConfiguration: {
|
|
29
37
|
CaseSensitive: false
|
|
@@ -41,22 +49,6 @@ var createAuthTemplate = () => {
|
|
|
41
49
|
Ref: "CognitoUserPool"
|
|
42
50
|
}
|
|
43
51
|
}
|
|
44
|
-
},
|
|
45
|
-
[CognitoIdentityPoolLogicalId]: {
|
|
46
|
-
Type: "AWS::Cognito::IdentityPool",
|
|
47
|
-
Properties: {
|
|
48
|
-
AllowUnauthenticatedIdentities: true,
|
|
49
|
-
CognitoIdentityProviders: [
|
|
50
|
-
{
|
|
51
|
-
ClientId: {
|
|
52
|
-
Ref: CognitoUserPoolClientLogicalId
|
|
53
|
-
},
|
|
54
|
-
ProviderName: {
|
|
55
|
-
"Fn::GetAtt": [CognitoUserPoolLogicalId, "ProviderName"]
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
]
|
|
59
|
-
}
|
|
60
52
|
}
|
|
61
53
|
},
|
|
62
54
|
Outputs: {
|
|
@@ -92,25 +84,60 @@ var createAuthTemplate = () => {
|
|
|
92
84
|
"Fn::Join": [":", [{ Ref: "AWS::StackName" }, "AppClientId"]]
|
|
93
85
|
}
|
|
94
86
|
}
|
|
95
|
-
},
|
|
96
|
-
IdentityPoolId: {
|
|
97
|
-
Description: "You use this value on Amplify Auth `identityPoolId`.",
|
|
98
|
-
Value: {
|
|
99
|
-
Ref: CognitoIdentityPoolLogicalId
|
|
100
|
-
},
|
|
101
|
-
Export: {
|
|
102
|
-
Name: {
|
|
103
|
-
"Fn::Join": [
|
|
104
|
-
":",
|
|
105
|
-
[{ Ref: "AWS::StackName" }, "CognitoIdentityPoolId"]
|
|
106
|
-
]
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
87
|
}
|
|
110
88
|
}
|
|
111
89
|
};
|
|
90
|
+
if (identityPool) {
|
|
91
|
+
template.Resources[CognitoIdentityPoolLogicalId] = {
|
|
92
|
+
Type: "AWS::Cognito::IdentityPool",
|
|
93
|
+
Properties: {
|
|
94
|
+
AllowUnauthenticatedIdentities: true,
|
|
95
|
+
CognitoIdentityProviders: [
|
|
96
|
+
{
|
|
97
|
+
ClientId: {
|
|
98
|
+
Ref: CognitoUserPoolClientLogicalId
|
|
99
|
+
},
|
|
100
|
+
ProviderName: {
|
|
101
|
+
"Fn::GetAtt": [CognitoUserPoolLogicalId, "ProviderName"]
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
if (roles) {
|
|
108
|
+
template.Resources.CognitoIdentityPoolRoleAttachment = {
|
|
109
|
+
Type: "AWS::Cognito::IdentityPoolRoleAttachment",
|
|
110
|
+
Properties: {
|
|
111
|
+
IdentityPoolId: {
|
|
112
|
+
Ref: CognitoIdentityPoolLogicalId
|
|
113
|
+
},
|
|
114
|
+
Roles: roles
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
if (!template.Outputs) {
|
|
119
|
+
template.Outputs = {};
|
|
120
|
+
}
|
|
121
|
+
template.Outputs.IdentityPoolId = {
|
|
122
|
+
Description: "You use this value on Amplify Auth `identityPoolId`.",
|
|
123
|
+
Value: {
|
|
124
|
+
Ref: CognitoIdentityPoolLogicalId
|
|
125
|
+
},
|
|
126
|
+
Export: {
|
|
127
|
+
Name: {
|
|
128
|
+
"Fn::Join": [
|
|
129
|
+
":",
|
|
130
|
+
[{ Ref: "AWS::StackName" }, "CognitoIdentityPoolId"]
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
112
136
|
return template;
|
|
113
137
|
};
|
|
138
|
+
createAuthTemplate.CognitoUserPoolLogicalId = CognitoUserPoolLogicalId;
|
|
139
|
+
createAuthTemplate.CognitoUserPoolClientLogicalId = CognitoUserPoolClientLogicalId;
|
|
140
|
+
createAuthTemplate.CognitoIdentityPoolLogicalId = CognitoIdentityPoolLogicalId;
|
|
114
141
|
export {
|
|
115
142
|
PASSWORD_MINIMUM_LENGTH,
|
|
116
143
|
createAuthTemplate
|
package/dist/index.d.ts
CHANGED
|
@@ -1,111 +1,40 @@
|
|
|
1
|
+
import { CloudFormationTemplate } from '@ttoss/cloudformation';
|
|
2
|
+
|
|
1
3
|
declare const PASSWORD_MINIMUM_LENGTH = 8;
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
RequireSymbols: boolean;
|
|
15
|
-
RequireUppercase: boolean;
|
|
16
|
-
TemporaryPasswordValidityDays: number;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
UsernameAttributes: string[];
|
|
20
|
-
UsernameConfiguration: {
|
|
21
|
-
CaseSensitive: boolean;
|
|
22
|
-
};
|
|
23
|
-
UserPoolName: {
|
|
24
|
-
Ref: string;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
CognitoUserPoolClient: {
|
|
29
|
-
Type: string;
|
|
30
|
-
Properties: {
|
|
31
|
-
SupportedIdentityProviders: string[];
|
|
32
|
-
UserPoolId: {
|
|
33
|
-
Ref: string;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
};
|
|
5
|
+
type Role = string | {
|
|
6
|
+
'Fn::ImportValue': string;
|
|
7
|
+
};
|
|
8
|
+
declare const createAuthTemplate: {
|
|
9
|
+
({ autoVerifiedAttributes, identityPool, roles, schema, }?: {
|
|
10
|
+
autoVerifiedAttributes?: false | ("email" | "phone_number")[] | null | undefined;
|
|
11
|
+
identityPool?: boolean | undefined;
|
|
12
|
+
roles?: {
|
|
13
|
+
authenticated?: Role | undefined;
|
|
14
|
+
unauthenticated?: Role | undefined;
|
|
15
|
+
} | undefined;
|
|
37
16
|
/**
|
|
38
|
-
* https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-
|
|
17
|
+
* https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cognito-userpool-schemaattribute.html
|
|
39
18
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
Ref: string;
|
|
60
|
-
};
|
|
61
|
-
Export: {
|
|
62
|
-
Name: {
|
|
63
|
-
'Fn::Join': (string | (string | {
|
|
64
|
-
Ref: string;
|
|
65
|
-
})[])[];
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
UserPoolId: {
|
|
70
|
-
Description: string;
|
|
71
|
-
Value: {
|
|
72
|
-
Ref: string;
|
|
73
|
-
};
|
|
74
|
-
Export: {
|
|
75
|
-
Name: {
|
|
76
|
-
'Fn::Join': (string | (string | {
|
|
77
|
-
Ref: string;
|
|
78
|
-
})[])[];
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
AppClientId: {
|
|
83
|
-
Description: string;
|
|
84
|
-
Value: {
|
|
85
|
-
Ref: string;
|
|
86
|
-
};
|
|
87
|
-
Export: {
|
|
88
|
-
Name: {
|
|
89
|
-
'Fn::Join': (string | (string | {
|
|
90
|
-
Ref: string;
|
|
91
|
-
})[])[];
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
IdentityPoolId: {
|
|
96
|
-
Description: string;
|
|
97
|
-
Value: {
|
|
98
|
-
Ref: string;
|
|
99
|
-
};
|
|
100
|
-
Export: {
|
|
101
|
-
Name: {
|
|
102
|
-
'Fn::Join': (string | (string | {
|
|
103
|
-
Ref: string;
|
|
104
|
-
})[])[];
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
};
|
|
108
|
-
};
|
|
19
|
+
schema?: {
|
|
20
|
+
AttributeDataType?: "Boolean" | "DateTime" | "Number" | "String" | undefined;
|
|
21
|
+
DeveloperOnlyAttribute?: boolean | undefined;
|
|
22
|
+
Mutable?: boolean | undefined;
|
|
23
|
+
Name?: string | undefined;
|
|
24
|
+
NumberAttributeConstraints?: {
|
|
25
|
+
MaxValue?: string | undefined;
|
|
26
|
+
MinValue?: string | undefined;
|
|
27
|
+
} | undefined;
|
|
28
|
+
Required?: boolean | undefined;
|
|
29
|
+
StringAttributeConstraints?: {
|
|
30
|
+
MaxLength: string;
|
|
31
|
+
MinLength: string;
|
|
32
|
+
} | undefined;
|
|
33
|
+
}[] | undefined;
|
|
34
|
+
}): CloudFormationTemplate;
|
|
35
|
+
CognitoUserPoolLogicalId: string;
|
|
36
|
+
CognitoUserPoolClientLogicalId: string;
|
|
37
|
+
CognitoIdentityPoolLogicalId: string;
|
|
109
38
|
};
|
|
110
39
|
|
|
111
40
|
export { PASSWORD_MINIMUM_LENGTH, createAuthTemplate };
|
package/dist/index.js
CHANGED
|
@@ -33,13 +33,20 @@ var PASSWORD_MINIMUM_LENGTH = 8;
|
|
|
33
33
|
var CognitoUserPoolLogicalId = "CognitoUserPool";
|
|
34
34
|
var CognitoUserPoolClientLogicalId = "CognitoUserPoolClient";
|
|
35
35
|
var CognitoIdentityPoolLogicalId = "CognitoIdentityPool";
|
|
36
|
-
var createAuthTemplate = (
|
|
36
|
+
var createAuthTemplate = ({
|
|
37
|
+
autoVerifiedAttributes = ["email"],
|
|
38
|
+
identityPool = true,
|
|
39
|
+
roles,
|
|
40
|
+
schema
|
|
41
|
+
} = {}) => {
|
|
42
|
+
const AutoVerifiedAttributes = Array.isArray(autoVerifiedAttributes) && autoVerifiedAttributes.length > 0 ? autoVerifiedAttributes : void 0;
|
|
37
43
|
const template = {
|
|
44
|
+
AWSTemplateFormatVersion: "2010-09-09",
|
|
38
45
|
Resources: {
|
|
39
46
|
[CognitoUserPoolLogicalId]: {
|
|
40
47
|
Type: "AWS::Cognito::UserPool",
|
|
41
48
|
Properties: {
|
|
42
|
-
AutoVerifiedAttributes
|
|
49
|
+
AutoVerifiedAttributes,
|
|
43
50
|
Policies: {
|
|
44
51
|
PasswordPolicy: {
|
|
45
52
|
MinimumLength: PASSWORD_MINIMUM_LENGTH,
|
|
@@ -50,6 +57,7 @@ var createAuthTemplate = () => {
|
|
|
50
57
|
TemporaryPasswordValidityDays: 30
|
|
51
58
|
}
|
|
52
59
|
},
|
|
60
|
+
Schema: schema,
|
|
53
61
|
UsernameAttributes: ["email"],
|
|
54
62
|
UsernameConfiguration: {
|
|
55
63
|
CaseSensitive: false
|
|
@@ -67,22 +75,6 @@ var createAuthTemplate = () => {
|
|
|
67
75
|
Ref: "CognitoUserPool"
|
|
68
76
|
}
|
|
69
77
|
}
|
|
70
|
-
},
|
|
71
|
-
[CognitoIdentityPoolLogicalId]: {
|
|
72
|
-
Type: "AWS::Cognito::IdentityPool",
|
|
73
|
-
Properties: {
|
|
74
|
-
AllowUnauthenticatedIdentities: true,
|
|
75
|
-
CognitoIdentityProviders: [
|
|
76
|
-
{
|
|
77
|
-
ClientId: {
|
|
78
|
-
Ref: CognitoUserPoolClientLogicalId
|
|
79
|
-
},
|
|
80
|
-
ProviderName: {
|
|
81
|
-
"Fn::GetAtt": [CognitoUserPoolLogicalId, "ProviderName"]
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
]
|
|
85
|
-
}
|
|
86
78
|
}
|
|
87
79
|
},
|
|
88
80
|
Outputs: {
|
|
@@ -118,25 +110,60 @@ var createAuthTemplate = () => {
|
|
|
118
110
|
"Fn::Join": [":", [{ Ref: "AWS::StackName" }, "AppClientId"]]
|
|
119
111
|
}
|
|
120
112
|
}
|
|
121
|
-
},
|
|
122
|
-
IdentityPoolId: {
|
|
123
|
-
Description: "You use this value on Amplify Auth `identityPoolId`.",
|
|
124
|
-
Value: {
|
|
125
|
-
Ref: CognitoIdentityPoolLogicalId
|
|
126
|
-
},
|
|
127
|
-
Export: {
|
|
128
|
-
Name: {
|
|
129
|
-
"Fn::Join": [
|
|
130
|
-
":",
|
|
131
|
-
[{ Ref: "AWS::StackName" }, "CognitoIdentityPoolId"]
|
|
132
|
-
]
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
113
|
}
|
|
136
114
|
}
|
|
137
115
|
};
|
|
116
|
+
if (identityPool) {
|
|
117
|
+
template.Resources[CognitoIdentityPoolLogicalId] = {
|
|
118
|
+
Type: "AWS::Cognito::IdentityPool",
|
|
119
|
+
Properties: {
|
|
120
|
+
AllowUnauthenticatedIdentities: true,
|
|
121
|
+
CognitoIdentityProviders: [
|
|
122
|
+
{
|
|
123
|
+
ClientId: {
|
|
124
|
+
Ref: CognitoUserPoolClientLogicalId
|
|
125
|
+
},
|
|
126
|
+
ProviderName: {
|
|
127
|
+
"Fn::GetAtt": [CognitoUserPoolLogicalId, "ProviderName"]
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
if (roles) {
|
|
134
|
+
template.Resources.CognitoIdentityPoolRoleAttachment = {
|
|
135
|
+
Type: "AWS::Cognito::IdentityPoolRoleAttachment",
|
|
136
|
+
Properties: {
|
|
137
|
+
IdentityPoolId: {
|
|
138
|
+
Ref: CognitoIdentityPoolLogicalId
|
|
139
|
+
},
|
|
140
|
+
Roles: roles
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
if (!template.Outputs) {
|
|
145
|
+
template.Outputs = {};
|
|
146
|
+
}
|
|
147
|
+
template.Outputs.IdentityPoolId = {
|
|
148
|
+
Description: "You use this value on Amplify Auth `identityPoolId`.",
|
|
149
|
+
Value: {
|
|
150
|
+
Ref: CognitoIdentityPoolLogicalId
|
|
151
|
+
},
|
|
152
|
+
Export: {
|
|
153
|
+
Name: {
|
|
154
|
+
"Fn::Join": [
|
|
155
|
+
":",
|
|
156
|
+
[{ Ref: "AWS::StackName" }, "CognitoIdentityPoolId"]
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
138
162
|
return template;
|
|
139
163
|
};
|
|
164
|
+
createAuthTemplate.CognitoUserPoolLogicalId = CognitoUserPoolLogicalId;
|
|
165
|
+
createAuthTemplate.CognitoUserPoolClientLogicalId = CognitoUserPoolClientLogicalId;
|
|
166
|
+
createAuthTemplate.CognitoIdentityPoolLogicalId = CognitoIdentityPoolLogicalId;
|
|
140
167
|
// Annotate the CommonJS export names for ESM import in node:
|
|
141
168
|
0 && (module.exports = {
|
|
142
169
|
PASSWORD_MINIMUM_LENGTH,
|
package/jest.config.ts
ADDED
package/package.json
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/cloud-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/esm/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "tsup"
|
|
7
|
+
"build": "tsup",
|
|
8
|
+
"test": "jest"
|
|
8
9
|
},
|
|
9
10
|
"typings": "./dist/index.d.ts",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@ttoss/cloudformation": "^0.4.0"
|
|
13
|
+
},
|
|
10
14
|
"devDependencies": {
|
|
11
|
-
"@ttoss/config": "^1.
|
|
12
|
-
"@types/jest": "^29.2.
|
|
15
|
+
"@ttoss/config": "^1.27.0",
|
|
16
|
+
"@types/jest": "^29.2.5",
|
|
13
17
|
"jest": "^29.3.1",
|
|
14
18
|
"typescript": "^4.9.4"
|
|
15
19
|
},
|
|
16
20
|
"publishConfig": {
|
|
17
21
|
"access": "public"
|
|
18
22
|
},
|
|
19
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "2bf304efc726a34b95859bb9b6fe8749c1a16844"
|
|
20
24
|
}
|