idea-aws 3.8.7 → 3.9.1
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/dist/src/cognito.d.ts
CHANGED
|
@@ -30,6 +30,13 @@ export declare class Cognito {
|
|
|
30
30
|
* Identify a user by its userId (sub), returning its attributes.
|
|
31
31
|
*/
|
|
32
32
|
getUserBySub(sub: string, cognitoUserPoolId: string): Promise<CognitoUserGeneric>;
|
|
33
|
+
/**
|
|
34
|
+
* Get all the users of the pool.
|
|
35
|
+
*/
|
|
36
|
+
getAllUsers(cognitoUserPoolId: string, options?: {
|
|
37
|
+
pagination?: string;
|
|
38
|
+
users: CognitoUser[];
|
|
39
|
+
}): Promise<CognitoUser[]>;
|
|
33
40
|
/**
|
|
34
41
|
* Create a new user (by its email) in the pool specified.
|
|
35
42
|
* @return userId of the new user
|
package/dist/src/cognito.js
CHANGED
|
@@ -72,6 +72,21 @@ class Cognito {
|
|
|
72
72
|
throw new Error('User not found');
|
|
73
73
|
return this.mapCognitoUserAttributesAsPlainObject(user);
|
|
74
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Get all the users of the pool.
|
|
77
|
+
*/
|
|
78
|
+
async getAllUsers(cognitoUserPoolId, options = { users: [] }) {
|
|
79
|
+
const params = { UserPoolId: cognitoUserPoolId };
|
|
80
|
+
if (options.pagination)
|
|
81
|
+
params.PaginationToken = options.pagination;
|
|
82
|
+
const res = await this.cognito.listUsers(params).promise();
|
|
83
|
+
const pagination = res.PaginationToken;
|
|
84
|
+
const users = options.users.concat(res.Users.map(u => new idea_toolbox_1.CognitoUser(this.mapCognitoUserAttributesAsPlainObject(u))));
|
|
85
|
+
if (pagination)
|
|
86
|
+
return await this.getAllUsers(cognitoUserPoolId, { pagination, users });
|
|
87
|
+
else
|
|
88
|
+
return users;
|
|
89
|
+
}
|
|
75
90
|
/**
|
|
76
91
|
* Create a new user (by its email) in the pool specified.
|
|
77
92
|
* @return userId of the new user
|
|
@@ -21,7 +21,7 @@ export declare abstract class ResourceController extends GenericController {
|
|
|
21
21
|
protected translations: any;
|
|
22
22
|
protected templateMatcher: RegExp;
|
|
23
23
|
constructor(event: any, callback: any, options?: ResourceControllerOptions);
|
|
24
|
-
handleRequest: () =>
|
|
24
|
+
handleRequest: () => void;
|
|
25
25
|
protected done(err: Error | null, res?: any, statusCode?: number): void;
|
|
26
26
|
/**
|
|
27
27
|
* To @override
|
|
@@ -81,12 +81,14 @@ export declare abstract class ResourceController extends GenericController {
|
|
|
81
81
|
protected storeLog(succeeded: boolean): void;
|
|
82
82
|
/**
|
|
83
83
|
* Check whether shared resource exists in the back-end (translation, template, etc.).
|
|
84
|
+
* Search for the specified file path in both the Lambda function's main folder and the layers folder.
|
|
84
85
|
*/
|
|
85
|
-
sharedResourceExists(
|
|
86
|
+
sharedResourceExists(filePath: string): boolean;
|
|
86
87
|
/**
|
|
87
88
|
* Load a shared resource in the back-end (translation, template, etc.).
|
|
89
|
+
* Search for the specified file path in both the Lambda function's main folder and the layers folder.
|
|
88
90
|
*/
|
|
89
|
-
loadSharedResource(
|
|
91
|
+
loadSharedResource(filePath: string): string;
|
|
90
92
|
/**
|
|
91
93
|
* Simulate an internal API request, invoking directly the lambda and therefore saving resources.
|
|
92
94
|
* @return the body of the response
|
|
@@ -16,72 +16,63 @@ class ResourceController extends genericController_1.GenericController {
|
|
|
16
16
|
///
|
|
17
17
|
/// REQUEST HANDLERS
|
|
18
18
|
///
|
|
19
|
-
this.handleRequest =
|
|
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
|
-
default:
|
|
46
|
-
this.done(new Error('Unsupported method'));
|
|
47
|
-
}
|
|
19
|
+
this.handleRequest = () => {
|
|
20
|
+
this.checkAuthBeforeRequest()
|
|
21
|
+
.then(() => {
|
|
22
|
+
let request;
|
|
23
|
+
if (this.resourceId)
|
|
24
|
+
switch (this.httpMethod) {
|
|
25
|
+
// resource/{resourceId}
|
|
26
|
+
case 'GET':
|
|
27
|
+
request = this.getResource();
|
|
28
|
+
break;
|
|
29
|
+
case 'POST':
|
|
30
|
+
request = this.postResource();
|
|
31
|
+
break;
|
|
32
|
+
case 'PUT':
|
|
33
|
+
request = this.putResource();
|
|
34
|
+
break;
|
|
35
|
+
case 'DELETE':
|
|
36
|
+
request = this.deleteResource();
|
|
37
|
+
break;
|
|
38
|
+
case 'PATCH':
|
|
39
|
+
request = this.patchResource();
|
|
40
|
+
break;
|
|
41
|
+
case 'HEAD':
|
|
42
|
+
request = this.headResource();
|
|
43
|
+
break;
|
|
44
|
+
default: /* nope */
|
|
48
45
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
this.done(new Error('Unsupported method'));
|
|
72
|
-
}
|
|
46
|
+
else
|
|
47
|
+
switch (this.httpMethod) {
|
|
48
|
+
// resource
|
|
49
|
+
case 'GET':
|
|
50
|
+
request = this.getResources();
|
|
51
|
+
break;
|
|
52
|
+
case 'POST':
|
|
53
|
+
request = this.postResources();
|
|
54
|
+
break;
|
|
55
|
+
case 'PUT':
|
|
56
|
+
request = this.putResources();
|
|
57
|
+
break;
|
|
58
|
+
case 'DELETE':
|
|
59
|
+
request = this.deleteResources();
|
|
60
|
+
break;
|
|
61
|
+
case 'PATCH':
|
|
62
|
+
request = this.patchResources();
|
|
63
|
+
break;
|
|
64
|
+
case 'HEAD':
|
|
65
|
+
request = this.headResources();
|
|
66
|
+
break;
|
|
67
|
+
default: /* nope */
|
|
73
68
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
this.done(new Error(errorMessage));
|
|
69
|
+
if (!request)
|
|
70
|
+
this.done(new Error('Unsupported method'));
|
|
71
|
+
else {
|
|
72
|
+
request.then((res) => this.done(null, res)).catch((err) => this.done(err));
|
|
79
73
|
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const errorMessage = err?.message || err?.errorMessage || 'Forbidden';
|
|
83
|
-
this.done(new Error(errorMessage));
|
|
84
|
-
}
|
|
74
|
+
})
|
|
75
|
+
.catch(err => this.done(new Error(err?.message ?? 'Forbidden')));
|
|
85
76
|
};
|
|
86
77
|
this.authorization = event.headers?.Authorization;
|
|
87
78
|
this.claims = event.requestContext?.authorizer?.claims;
|
|
@@ -126,80 +117,80 @@ class ResourceController extends genericController_1.GenericController {
|
|
|
126
117
|
/**
|
|
127
118
|
* To @override
|
|
128
119
|
*/
|
|
129
|
-
|
|
130
|
-
return;
|
|
120
|
+
checkAuthBeforeRequest() {
|
|
121
|
+
return new Promise(resolve => resolve());
|
|
131
122
|
}
|
|
132
123
|
/**
|
|
133
124
|
* To @override
|
|
134
125
|
*/
|
|
135
|
-
|
|
136
|
-
|
|
126
|
+
getResource() {
|
|
127
|
+
return new Promise((_, reject) => reject(new Error('Unsupported method')));
|
|
137
128
|
}
|
|
138
129
|
/**
|
|
139
130
|
* To @override
|
|
140
131
|
*/
|
|
141
|
-
|
|
142
|
-
|
|
132
|
+
postResource() {
|
|
133
|
+
return new Promise((_, reject) => reject(new Error('Unsupported method')));
|
|
143
134
|
}
|
|
144
135
|
/**
|
|
145
136
|
* To @override
|
|
146
137
|
*/
|
|
147
|
-
|
|
148
|
-
|
|
138
|
+
putResource() {
|
|
139
|
+
return new Promise((_, reject) => reject(new Error('Unsupported method')));
|
|
149
140
|
}
|
|
150
141
|
/**
|
|
151
142
|
* To @override
|
|
152
143
|
*/
|
|
153
|
-
|
|
154
|
-
|
|
144
|
+
deleteResource() {
|
|
145
|
+
return new Promise((_, reject) => reject(new Error('Unsupported method')));
|
|
155
146
|
}
|
|
156
147
|
/**
|
|
157
148
|
* To @override
|
|
158
149
|
*/
|
|
159
|
-
|
|
160
|
-
|
|
150
|
+
headResource() {
|
|
151
|
+
return new Promise((_, reject) => reject(new Error('Unsupported method')));
|
|
161
152
|
}
|
|
162
153
|
/**
|
|
163
154
|
* To @override
|
|
164
155
|
*/
|
|
165
|
-
|
|
166
|
-
|
|
156
|
+
getResources() {
|
|
157
|
+
return new Promise((_, reject) => reject(new Error('Unsupported method')));
|
|
167
158
|
}
|
|
168
159
|
/**
|
|
169
160
|
* To @override
|
|
170
161
|
*/
|
|
171
|
-
|
|
172
|
-
|
|
162
|
+
postResources() {
|
|
163
|
+
return new Promise((_, reject) => reject(new Error('Unsupported method')));
|
|
173
164
|
}
|
|
174
165
|
/**
|
|
175
166
|
* To @override
|
|
176
167
|
*/
|
|
177
|
-
|
|
178
|
-
|
|
168
|
+
putResources() {
|
|
169
|
+
return new Promise((_, reject) => reject(new Error('Unsupported method')));
|
|
179
170
|
}
|
|
180
171
|
/**
|
|
181
172
|
* To @override
|
|
182
173
|
*/
|
|
183
|
-
|
|
184
|
-
|
|
174
|
+
patchResource() {
|
|
175
|
+
return new Promise((_, reject) => reject(new Error('Unsupported method')));
|
|
185
176
|
}
|
|
186
177
|
/**
|
|
187
178
|
* To @override
|
|
188
179
|
*/
|
|
189
|
-
|
|
190
|
-
|
|
180
|
+
patchResources() {
|
|
181
|
+
return new Promise((_, reject) => reject(new Error('Unsupported method')));
|
|
191
182
|
}
|
|
192
183
|
/**
|
|
193
184
|
* To @override
|
|
194
185
|
*/
|
|
195
|
-
|
|
196
|
-
|
|
186
|
+
deleteResources() {
|
|
187
|
+
return new Promise((_, reject) => reject(new Error('Unsupported method')));
|
|
197
188
|
}
|
|
198
189
|
/**
|
|
199
190
|
* To @override
|
|
200
191
|
*/
|
|
201
|
-
|
|
202
|
-
|
|
192
|
+
headResources() {
|
|
193
|
+
return new Promise((_, reject) => reject(new Error('Unsupported method')));
|
|
203
194
|
}
|
|
204
195
|
///
|
|
205
196
|
/// HELPERS
|
|
@@ -226,15 +217,22 @@ class ResourceController extends genericController_1.GenericController {
|
|
|
226
217
|
}
|
|
227
218
|
/**
|
|
228
219
|
* Check whether shared resource exists in the back-end (translation, template, etc.).
|
|
220
|
+
* Search for the specified file path in both the Lambda function's main folder and the layers folder.
|
|
229
221
|
*/
|
|
230
|
-
sharedResourceExists(
|
|
231
|
-
return (0, fs_1.existsSync)(`assets/${
|
|
222
|
+
sharedResourceExists(filePath) {
|
|
223
|
+
return (0, fs_1.existsSync)(`assets/${filePath}`) || (0, fs_1.existsSync)(`/opt/nodejs/assets/${filePath}`);
|
|
232
224
|
}
|
|
233
225
|
/**
|
|
234
226
|
* Load a shared resource in the back-end (translation, template, etc.).
|
|
227
|
+
* Search for the specified file path in both the Lambda function's main folder and the layers folder.
|
|
235
228
|
*/
|
|
236
|
-
loadSharedResource(
|
|
237
|
-
|
|
229
|
+
loadSharedResource(filePath) {
|
|
230
|
+
let path = null;
|
|
231
|
+
if ((0, fs_1.existsSync)(`assets/${filePath}`))
|
|
232
|
+
path = `assets/${filePath}`;
|
|
233
|
+
else if ((0, fs_1.existsSync)(`/opt/nodejs/assets/${filePath}`))
|
|
234
|
+
path = `/opt/nodejs/assets/${filePath}`;
|
|
235
|
+
return path ? (0, fs_1.readFileSync)(path, { encoding: 'utf-8' }) : null;
|
|
238
236
|
}
|
|
239
237
|
///
|
|
240
238
|
/// MANAGE INTERNAL API REQUESTS (lambda invokes masked as API requests)
|
package/dist/src/ses.d.ts
CHANGED
|
@@ -112,9 +112,10 @@ export interface TemplatedEmailData extends BasicEmailData {
|
|
|
112
112
|
template: string;
|
|
113
113
|
/**
|
|
114
114
|
* An object containing key-value pairs of variable-content to substitute.
|
|
115
|
+
* It supports handlebars.js templating.
|
|
115
116
|
*/
|
|
116
117
|
templateData: {
|
|
117
|
-
[variable: string]:
|
|
118
|
+
[variable: string]: any;
|
|
118
119
|
};
|
|
119
120
|
/**
|
|
120
121
|
* The name of the configuration set to use for the sending.
|