idea-aws 3.8.8 → 3.9.2

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.
@@ -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
@@ -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
@@ -229,7 +229,7 @@ class ResourceController extends genericController_1.GenericController {
229
229
  * Search for the specified file path in both the Lambda function's main folder and the layers folder.
230
230
  */
231
231
  sharedResourceExists(filePath) {
232
- return (0, fs_1.existsSync)(`assets/${filePath}`) || (0, fs_1.existsSync)(`/opts/nodejs/assets/${filePath}`);
232
+ return (0, fs_1.existsSync)(`assets/${filePath}`) || (0, fs_1.existsSync)(`/opt/nodejs/assets/${filePath}`);
233
233
  }
234
234
  /**
235
235
  * Load a shared resource in the back-end (translation, template, etc.).
@@ -239,8 +239,8 @@ class ResourceController extends genericController_1.GenericController {
239
239
  let path = null;
240
240
  if ((0, fs_1.existsSync)(`assets/${filePath}`))
241
241
  path = `assets/${filePath}`;
242
- else if ((0, fs_1.existsSync)(`/opts/nodejs/assets/${filePath}`))
243
- path = `/opts/nodejs/assets/${filePath}`;
242
+ else if ((0, fs_1.existsSync)(`/opt/nodejs/assets/${filePath}`))
243
+ path = `/opt/nodejs/assets/${filePath}`;
244
244
  return path ? (0, fs_1.readFileSync)(path, { encoding: 'utf-8' }) : null;
245
245
  }
246
246
  ///
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "idea-aws",
3
- "version": "3.8.8",
3
+ "version": "3.9.2",
4
4
  "description": "AWS wrappers to use in IDEA's back-ends",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",