@ttoss/cloud-auth 0.4.0 → 0.6.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.
@@ -31,7 +31,7 @@ SF:src/template.ts
31
31
  FN:16,createAuthTemplate
32
32
  FNF:1
33
33
  FNH:1
34
- FNDA:11,createAuthTemplate
34
+ FNDA:12,createAuthTemplate
35
35
  DA:1,1
36
36
  DA:2,1
37
37
  DA:3,1
@@ -48,140 +48,140 @@ DA:13,1
48
48
  DA:14,1
49
49
  DA:15,1
50
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
51
+ DA:17,12
52
+ DA:18,12
53
+ DA:19,12
54
+ DA:20,12
55
+ DA:21,12
56
+ DA:22,12
57
+ DA:23,12
58
+ DA:24,12
59
+ DA:25,12
60
+ DA:26,12
61
+ DA:27,12
62
+ DA:28,12
63
+ DA:29,12
64
+ DA:30,12
65
+ DA:31,12
66
+ DA:32,12
67
+ DA:33,12
68
+ DA:34,12
69
+ DA:35,12
70
+ DA:36,12
71
+ DA:37,12
72
+ DA:38,12
73
+ DA:39,12
74
+ DA:40,12
75
+ DA:41,12
76
+ DA:42,12
77
+ DA:43,12
78
+ DA:44,12
79
+ DA:45,12
80
+ DA:46,12
81
+ DA:47,12
82
+ DA:48,12
83
+ DA:49,12
84
+ DA:50,12
85
+ DA:51,9
86
+ DA:52,12
87
+ DA:53,12
88
+ DA:54,12
89
+ DA:55,12
90
+ DA:56,12
91
+ DA:57,12
92
+ DA:58,12
93
+ DA:59,12
94
+ DA:60,12
95
+ DA:61,12
96
+ DA:62,12
97
+ DA:63,12
98
+ DA:64,12
99
+ DA:65,12
100
+ DA:66,12
101
+ DA:67,12
102
+ DA:68,12
103
+ DA:69,12
104
+ DA:70,12
105
+ DA:71,12
106
+ DA:72,12
107
+ DA:73,12
108
+ DA:74,12
109
+ DA:75,12
110
+ DA:76,12
111
+ DA:77,12
112
+ DA:78,12
113
+ DA:79,12
114
+ DA:80,12
115
+ DA:81,12
116
+ DA:82,12
117
+ DA:83,12
118
+ DA:84,12
119
+ DA:85,12
120
+ DA:86,12
121
+ DA:87,12
122
+ DA:88,12
123
+ DA:89,12
124
+ DA:90,12
125
+ DA:91,12
126
+ DA:92,12
127
+ DA:93,12
128
+ DA:94,12
129
+ DA:95,12
130
+ DA:96,12
131
+ DA:97,12
132
+ DA:98,12
133
+ DA:99,12
134
+ DA:100,12
135
+ DA:101,12
136
+ DA:102,12
137
+ DA:103,12
138
+ DA:104,12
139
+ DA:105,12
140
+ DA:106,12
141
+ DA:107,12
142
+ DA:108,12
143
+ DA:109,12
144
+ DA:110,12
145
+ DA:111,12
146
+ DA:112,12
147
+ DA:113,12
148
+ DA:114,12
149
+ DA:115,12
150
+ DA:116,12
151
+ DA:117,12
152
+ DA:118,12
153
+ DA:119,12
154
+ DA:120,12
155
+ DA:121,12
156
+ DA:122,12
157
+ DA:123,12
158
+ DA:124,12
159
+ DA:125,12
160
+ DA:126,12
161
+ DA:127,12
162
+ DA:128,12
163
+ DA:129,12
164
+ DA:130,11
165
+ DA:131,11
166
+ DA:132,11
167
+ DA:133,11
168
+ DA:134,11
169
+ DA:135,11
170
+ DA:136,11
171
+ DA:137,11
172
+ DA:138,11
173
+ DA:139,11
174
+ DA:140,11
175
+ DA:141,11
176
+ DA:142,11
177
+ DA:143,11
178
+ DA:144,11
179
+ DA:145,11
180
+ DA:146,11
181
+ DA:147,11
182
+ DA:148,11
183
+ DA:149,11
184
+ DA:150,11
185
185
  DA:151,1
186
186
  DA:152,1
187
187
  DA:153,1
@@ -193,43 +193,45 @@ DA:158,1
193
193
  DA:159,1
194
194
  DA:160,1
195
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
196
+ DA:162,1
197
+ DA:163,1
198
+ DA:164,11
199
+ DA:165,11
200
+ DA:166,0
201
+ DA:167,0
202
+ DA:168,11
203
+ DA:169,11
204
+ DA:170,11
205
+ DA:171,11
206
+ DA:172,11
207
+ DA:173,11
208
+ DA:174,11
209
+ DA:175,11
210
+ DA:176,11
211
+ DA:177,11
212
+ DA:178,11
213
+ DA:179,11
214
+ DA:180,11
215
+ DA:181,11
216
216
  DA:182,11
217
217
  DA:183,11
218
- DA:184,11
219
- DA:185,1
220
- DA:186,1
218
+ DA:184,12
219
+ DA:185,12
220
+ DA:186,12
221
221
  DA:187,1
222
222
  DA:188,1
223
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
224
+ DA:190,1
225
+ DA:191,1
226
+ LF:191
227
+ LH:189
228
+ BRDA:16,0,0,12
229
+ BRDA:50,1,0,10
230
+ BRDA:51,2,0,9
231
+ BRDA:52,3,0,3
232
+ BRDA:129,4,0,11
233
+ BRDA:150,5,0,1
234
+ BRDA:165,6,0,0
233
235
  BRF:7
234
236
  BRH:6
235
237
  end_of_record
package/dist/esm/index.js CHANGED
@@ -11,9 +11,10 @@ var createAuthTemplate = ({
11
11
  autoVerifiedAttributes = ["email"],
12
12
  identityPool = true,
13
13
  roles,
14
- schema
14
+ schema,
15
+ usernameAttributes = ["email"]
15
16
  } = {}) => {
16
- const AutoVerifiedAttributes = Array.isArray(autoVerifiedAttributes) && autoVerifiedAttributes.length > 0 ? autoVerifiedAttributes : void 0;
17
+ const AutoVerifiedAttributes = Array.isArray(autoVerifiedAttributes) && autoVerifiedAttributes.length > 0 ? autoVerifiedAttributes : [];
17
18
  const template = {
18
19
  AWSTemplateFormatVersion: "2010-09-09",
19
20
  Resources: {
@@ -32,7 +33,7 @@ var createAuthTemplate = ({
32
33
  }
33
34
  },
34
35
  Schema: schema,
35
- UsernameAttributes: ["email"],
36
+ UsernameAttributes: usernameAttributes,
36
37
  UsernameConfiguration: {
37
38
  CaseSensitive: false
38
39
  },
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ type Role = string | {
6
6
  'Fn::ImportValue': string;
7
7
  };
8
8
  declare const createAuthTemplate: {
9
- ({ autoVerifiedAttributes, identityPool, roles, schema, }?: {
9
+ ({ autoVerifiedAttributes, identityPool, roles, schema, usernameAttributes, }?: {
10
10
  autoVerifiedAttributes?: false | ("email" | "phone_number")[] | null | undefined;
11
11
  identityPool?: boolean | undefined;
12
12
  roles?: {
@@ -31,6 +31,7 @@ declare const createAuthTemplate: {
31
31
  MinLength: string;
32
32
  } | undefined;
33
33
  }[] | undefined;
34
+ usernameAttributes?: ("email" | "phone_number")[] | null | undefined;
34
35
  }): CloudFormationTemplate;
35
36
  CognitoUserPoolLogicalId: string;
36
37
  CognitoUserPoolClientLogicalId: string;
package/dist/index.js CHANGED
@@ -37,9 +37,10 @@ var createAuthTemplate = ({
37
37
  autoVerifiedAttributes = ["email"],
38
38
  identityPool = true,
39
39
  roles,
40
- schema
40
+ schema,
41
+ usernameAttributes = ["email"]
41
42
  } = {}) => {
42
- const AutoVerifiedAttributes = Array.isArray(autoVerifiedAttributes) && autoVerifiedAttributes.length > 0 ? autoVerifiedAttributes : void 0;
43
+ const AutoVerifiedAttributes = Array.isArray(autoVerifiedAttributes) && autoVerifiedAttributes.length > 0 ? autoVerifiedAttributes : [];
43
44
  const template = {
44
45
  AWSTemplateFormatVersion: "2010-09-09",
45
46
  Resources: {
@@ -58,7 +59,7 @@ var createAuthTemplate = ({
58
59
  }
59
60
  },
60
61
  Schema: schema,
61
- UsernameAttributes: ["email"],
62
+ UsernameAttributes: usernameAttributes,
62
63
  UsernameConfiguration: {
63
64
  CaseSensitive: false
64
65
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/cloud-auth",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/esm/index.js",
6
6
  "scripts": {
@@ -9,16 +9,16 @@
9
9
  },
10
10
  "typings": "./dist/index.d.ts",
11
11
  "dependencies": {
12
- "@ttoss/cloudformation": "^0.4.0"
12
+ "@ttoss/cloudformation": "^0.5.0"
13
13
  },
14
14
  "devDependencies": {
15
- "@ttoss/config": "^1.27.0",
16
- "@types/jest": "^29.2.5",
17
- "jest": "^29.3.1",
15
+ "@ttoss/config": "^1.28.0",
16
+ "@types/jest": "^29.4.0",
17
+ "jest": "^29.4.1",
18
18
  "typescript": "^4.9.4"
19
19
  },
20
20
  "publishConfig": {
21
21
  "access": "public"
22
22
  },
23
- "gitHead": "2bf304efc726a34b95859bb9b6fe8749c1a16844"
23
+ "gitHead": "7852c1c6c570e30cd03a603902f45fb4849c7701"
24
24
  }
package/src/template.ts CHANGED
@@ -18,6 +18,7 @@ export const createAuthTemplate = ({
18
18
  identityPool = true,
19
19
  roles,
20
20
  schema,
21
+ usernameAttributes = ['email'],
21
22
  }: {
22
23
  autoVerifiedAttributes?: Array<'email' | 'phone_number'> | null | false;
23
24
  identityPool?: boolean;
@@ -43,11 +44,12 @@ export const createAuthTemplate = ({
43
44
  MinLength: string;
44
45
  };
45
46
  }[];
47
+ usernameAttributes?: Array<'email' | 'phone_number'> | null;
46
48
  } = {}) => {
47
49
  const AutoVerifiedAttributes =
48
50
  Array.isArray(autoVerifiedAttributes) && autoVerifiedAttributes.length > 0
49
51
  ? autoVerifiedAttributes
50
- : undefined;
52
+ : [];
51
53
 
52
54
  const template: CloudFormationTemplate = {
53
55
  AWSTemplateFormatVersion: '2010-09-09',
@@ -67,7 +69,7 @@ export const createAuthTemplate = ({
67
69
  },
68
70
  },
69
71
  Schema: schema,
70
- UsernameAttributes: ['email'],
72
+ UsernameAttributes: usernameAttributes,
71
73
  UsernameConfiguration: {
72
74
  CaseSensitive: false,
73
75
  },
@@ -37,7 +37,7 @@ test.each([[], null, false])(
37
37
  const template = createAuthTemplate({ autoVerifiedAttributes });
38
38
  expect(
39
39
  template.Resources.CognitoUserPool.Properties.AutoVerifiedAttributes
40
- ).toBeUndefined();
40
+ ).toEqual([]);
41
41
  }
42
42
  );
43
43
 
@@ -71,3 +71,10 @@ test('should not have identity pool role attachment without roles', () => {
71
71
  const template = createAuthTemplate();
72
72
  expect(template.Resources.CognitoIdentityPoolRoleAttachment).toBeUndefined();
73
73
  });
74
+
75
+ test('default usernameAttributes should be email', () => {
76
+ const template = createAuthTemplate();
77
+ expect(
78
+ template.Resources.CognitoUserPool.Properties.UsernameAttributes
79
+ ).toEqual(['email']);
80
+ });