idea-aws 4.4.6 → 4.4.8

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.
@@ -32,6 +32,10 @@ export declare class Cognito {
32
32
  * Identify a user by its userId (sub), returning its attributes.
33
33
  */
34
34
  getUserBySub(sub: string, userPoolId: string): Promise<CognitoUserGeneric>;
35
+ /**
36
+ * Get the list of groups of a user by its email address.
37
+ */
38
+ getUserGroupsByEmail(email: string, userPoolId: string): Promise<string[]>;
35
39
  /**
36
40
  * List all the users of the pool.
37
41
  */
@@ -99,6 +99,14 @@ class Cognito {
99
99
  throw new Error('User not found');
100
100
  return this.mapCognitoUserAttributesAsPlainObject(Users[0]);
101
101
  }
102
+ /**
103
+ * Get the list of groups of a user by its email address.
104
+ */
105
+ async getUserGroupsByEmail(email, userPoolId) {
106
+ const command = new CognitoIP.AdminListGroupsForUserCommand({ UserPoolId: userPoolId, Username: email });
107
+ const { Groups } = await this.client.send(command);
108
+ return Groups.map(x => x.GroupName);
109
+ }
102
110
  /**
103
111
  * List all the users of the pool.
104
112
  */
@@ -32,6 +32,8 @@ export declare abstract class ResourceController extends GenericController {
32
32
  protected logRequestsWithKey: string;
33
33
  protected metrics: CloudWatchMetrics;
34
34
  protected tracer: Tracer;
35
+ protected tracerLambdaSegment: any;
36
+ protected tracerRCSegment: any;
35
37
  protected currentLang: string;
36
38
  protected defaultLang: string;
37
39
  protected translations: any;
@@ -55,12 +55,11 @@ class ResourceController extends genericController_1.GenericController {
55
55
  if (this.initError)
56
56
  return;
57
57
  this.logger.info('START', { event: this.getEventSummary() });
58
- let lambdaSegment, rcSegment;
59
58
  if (this.tracer) {
60
- lambdaSegment = this.tracer.getSegment();
61
- if (lambdaSegment) {
62
- rcSegment = lambdaSegment.addNewSubsegment('RC');
63
- this.tracer.setSegment(rcSegment);
59
+ this.tracerLambdaSegment = this.tracer.getSegment();
60
+ if (this.tracerLambdaSegment) {
61
+ this.tracerRCSegment = this.tracerLambdaSegment.addNewSubsegment('RC');
62
+ this.tracer.setSegment(this.tracerRCSegment);
64
63
  }
65
64
  this.tracer.annotateColdStart();
66
65
  this.tracer.addServiceNameAnnotation();
@@ -129,12 +128,6 @@ class ResourceController extends genericController_1.GenericController {
129
128
  catch (err) {
130
129
  this.done(this.handleControllerError(err, 'AUTH-CHECK-ERROR', 'Forbidden'));
131
130
  }
132
- finally {
133
- if (this.tracer && lambdaSegment && rcSegment) {
134
- rcSegment.close();
135
- this.tracer.setSegment(lambdaSegment);
136
- }
137
- }
138
131
  };
139
132
  this.event = event;
140
133
  this.callback = callback;
@@ -251,6 +244,12 @@ class ResourceController extends genericController_1.GenericController {
251
244
  }
252
245
  else
253
246
  this.logger.info('END-SUCCESS', finalLogContent);
247
+ if (this.tracer) {
248
+ if (this.tracerRCSegment)
249
+ this.tracerRCSegment.close();
250
+ if (this.tracerLambdaSegment)
251
+ this.tracer.setSegment(this.tracerLambdaSegment);
252
+ }
254
253
  if (this.logRequestsWithKey)
255
254
  this.storeLog(!error);
256
255
  if (this.metrics)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "idea-aws",
3
- "version": "4.4.6",
3
+ "version": "4.4.8",
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",