idea-aws 3.13.6 → 3.14.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'source-map-support/register';
|
|
2
2
|
import { APIGatewayProxyEventV2, APIGatewayProxyEvent, Callback } from 'aws-lambda';
|
|
3
|
-
import { CognitoUser } from 'idea-toolbox';
|
|
3
|
+
import { CognitoUser, Auth0User } from 'idea-toolbox';
|
|
4
4
|
import { Logger } from './logger';
|
|
5
5
|
import { GenericController, GenericControllerOptions } from './genericController';
|
|
6
6
|
/**
|
|
@@ -14,6 +14,7 @@ export declare abstract class ResourceController extends GenericController {
|
|
|
14
14
|
protected claims: any;
|
|
15
15
|
protected principalId: string;
|
|
16
16
|
protected cognitoUser: CognitoUser;
|
|
17
|
+
protected auth0User: Auth0User;
|
|
17
18
|
protected stage: string;
|
|
18
19
|
protected httpMethod: string;
|
|
19
20
|
protected body: any;
|
|
@@ -32,6 +33,10 @@ export declare abstract class ResourceController extends GenericController {
|
|
|
32
33
|
constructor(event: APIGatewayProxyEventV2 | APIGatewayProxyEvent, callback: Callback, options?: ResourceControllerOptions);
|
|
33
34
|
private initFromEventV2;
|
|
34
35
|
private initFromEventV1;
|
|
36
|
+
/**
|
|
37
|
+
* Force the parsing of a query parameter as an array of strings.
|
|
38
|
+
*/
|
|
39
|
+
protected getQueryParamAsArray(paramName: string): string[];
|
|
35
40
|
handleRequest: () => Promise<void>;
|
|
36
41
|
private controlHandlerError;
|
|
37
42
|
protected done(err: any, res?: any, statusCode?: number): void;
|
|
@@ -119,6 +119,7 @@ class ResourceController extends genericController_1.GenericController {
|
|
|
119
119
|
const contextFromAuthorizer = authorizer.lambda ?? authorizer.jwt?.claims ?? {};
|
|
120
120
|
this.principalId = contextFromAuthorizer.principalId ?? contextFromAuthorizer.sub ?? null;
|
|
121
121
|
this.cognitoUser = authorizer.jwt?.claims ? new idea_toolbox_1.CognitoUser(authorizer.jwt?.claims) : null;
|
|
122
|
+
this.auth0User = contextFromAuthorizer.auth0User ? new idea_toolbox_1.Auth0User(contextFromAuthorizer.auth0User) : null;
|
|
122
123
|
this.stage = event.requestContext.stage;
|
|
123
124
|
this.httpMethod = event.requestContext.http.method;
|
|
124
125
|
this.resource = event.routeKey.replace('+', ''); // {proxy+} -> {proxy}
|
|
@@ -140,6 +141,7 @@ class ResourceController extends genericController_1.GenericController {
|
|
|
140
141
|
this.claims = event.requestContext.authorizer?.claims || {};
|
|
141
142
|
this.principalId = this.claims.sub;
|
|
142
143
|
this.cognitoUser = this.principalId ? new idea_toolbox_1.CognitoUser(this.claims) : null;
|
|
144
|
+
this.auth0User = null;
|
|
143
145
|
this.stage = event.requestContext.stage;
|
|
144
146
|
this.httpMethod = event.httpMethod;
|
|
145
147
|
this.resource = event.resource.replace('+', ''); // {proxy+} -> {proxy}
|
|
@@ -156,6 +158,17 @@ class ResourceController extends genericController_1.GenericController {
|
|
|
156
158
|
throw new RCError('Malformed body');
|
|
157
159
|
}
|
|
158
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Force the parsing of a query parameter as an array of strings.
|
|
163
|
+
*/
|
|
164
|
+
getQueryParamAsArray(paramName) {
|
|
165
|
+
if (!this.queryParams[paramName])
|
|
166
|
+
return [];
|
|
167
|
+
else if (Array.isArray(this.queryParams[paramName]))
|
|
168
|
+
return this.queryParams[paramName];
|
|
169
|
+
else
|
|
170
|
+
return String(this.queryParams[paramName]).split(',');
|
|
171
|
+
}
|
|
159
172
|
controlHandlerError(err = {}, context, replaceWithErrorMessage) {
|
|
160
173
|
if (err instanceof RCError)
|
|
161
174
|
return new Error(err.message);
|
package/dist/src/s3.js
CHANGED
|
@@ -72,7 +72,7 @@ class S3 {
|
|
|
72
72
|
* Get an object from a S3 bucket.
|
|
73
73
|
*/
|
|
74
74
|
async getObject(options) {
|
|
75
|
-
logger.debug(`S3 get object: ${options.
|
|
75
|
+
logger.debug(`S3 get object: ${options.key}`);
|
|
76
76
|
const result = await this.s3.getObject({ Bucket: options.bucket, Key: options.key }).promise();
|
|
77
77
|
switch (options.type) {
|
|
78
78
|
case GetObjectTypes.JSON:
|
package/dist/src/sns.js
CHANGED
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SNS = void 0;
|
|
4
4
|
const aws_sdk_1 = require("aws-sdk");
|
|
5
5
|
const idea_toolbox_1 = require("idea-toolbox");
|
|
6
|
+
const logger_1 = require("./logger");
|
|
7
|
+
const logger = new logger_1.Logger();
|
|
6
8
|
/**
|
|
7
9
|
* A wrapper for AWS Simple Notification Service.
|
|
8
10
|
*/
|
|
@@ -26,7 +28,7 @@ class SNS {
|
|
|
26
28
|
default:
|
|
27
29
|
throw new Error('Unsupported platform');
|
|
28
30
|
}
|
|
29
|
-
|
|
31
|
+
logger.debug('SNS ADD PLATFORM ENDPOINT');
|
|
30
32
|
const result = await new aws_sdk_1.SNS({ apiVersion: '2010-03-31', region: snsParams.region })
|
|
31
33
|
.createPlatformEndpoint({ PlatformApplicationArn: platformARN, Token: token })
|
|
32
34
|
.promise();
|
|
@@ -55,7 +57,7 @@ class SNS {
|
|
|
55
57
|
default:
|
|
56
58
|
throw new Error('Unsupported platform');
|
|
57
59
|
}
|
|
58
|
-
|
|
60
|
+
logger.debug('SNS PUBLISH IN TOPIC');
|
|
59
61
|
return await new aws_sdk_1.SNS({ apiVersion: '2010-03-31', region: snsParams.region })
|
|
60
62
|
.publish({ MessageStructure: 'json', Message: JSON.stringify(structuredMessage), TargetArn: snsParams.endpoint })
|
|
61
63
|
.promise();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "idea-aws",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.14.0",
|
|
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",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://iter-idea.github.io/IDEA-AWS",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"idea-toolbox": "^6.
|
|
38
|
+
"idea-toolbox": "^6.6.1",
|
|
39
39
|
"nanoid": "^3.3.4",
|
|
40
40
|
"nodemailer": "^6.7.7",
|
|
41
41
|
"shortid": "^2.2.16",
|