dromanis.finora.functions.common 3.5.1 → 3.10.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/corsHandler.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda';
|
|
2
2
|
export declare class corsHandler {
|
|
3
3
|
private allowedOrigins;
|
|
4
|
+
constructor();
|
|
4
5
|
private getOriginHeader;
|
|
5
6
|
handleWithCors(response: APIGatewayProxyResult, event: APIGatewayProxyEvent): APIGatewayProxyResult;
|
|
6
7
|
handleOptionsMethod(event: APIGatewayProxyEvent): APIGatewayProxyResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"corsHandler.d.ts","sourceRoot":"","sources":["../src/corsHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEzE,qBAAa,WAAW;
|
|
1
|
+
{"version":3,"file":"corsHandler.d.ts","sourceRoot":"","sources":["../src/corsHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEzE,qBAAa,WAAW;IACpB,OAAO,CAAC,cAAc,CAAW;;IAMjC,OAAO,CAAC,eAAe;IAKhB,cAAc,CACjB,QAAQ,EAAE,qBAAqB,EAC/B,KAAK,EAAE,oBAAoB,GAC5B,qBAAqB;IAkBjB,mBAAmB,CAAC,KAAK,EAAE,oBAAoB,GAAG,qBAAqB;CAQjF"}
|
package/dist/corsHandler.js
CHANGED
|
@@ -6,16 +6,18 @@ class corsHandler {
|
|
|
6
6
|
this.allowedOrigins = ['https://finnora.io', 'http://localhost:4050'];
|
|
7
7
|
}
|
|
8
8
|
getOriginHeader(event) {
|
|
9
|
-
|
|
9
|
+
const origin = event.headers['origin'] || event.headers['Origin'];
|
|
10
|
+
return origin;
|
|
10
11
|
}
|
|
11
12
|
handleWithCors(response, event) {
|
|
12
13
|
const origin = this.getOriginHeader(event);
|
|
13
|
-
const isAllowed = origin && this.allowedOrigins.includes(origin);
|
|
14
|
+
const isAllowed = !!(origin && this.allowedOrigins.includes(origin));
|
|
15
|
+
const allowedOrigin = (isAllowed && origin) ? origin : this.allowedOrigins[0];
|
|
14
16
|
return {
|
|
15
17
|
...response,
|
|
16
18
|
headers: {
|
|
17
19
|
...(response.headers || {}),
|
|
18
|
-
'Access-Control-Allow-Origin':
|
|
20
|
+
'Access-Control-Allow-Origin': allowedOrigin,
|
|
19
21
|
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
|
|
20
22
|
'Access-Control-Allow-Methods': 'GET,POST,PUT,DELETE,OPTIONS',
|
|
21
23
|
'Access-Control-Allow-Credentials': 'true',
|
|
@@ -23,9 +25,10 @@ class corsHandler {
|
|
|
23
25
|
};
|
|
24
26
|
}
|
|
25
27
|
handleOptionsMethod(event) {
|
|
28
|
+
console.log('Handling OPTIONS preflight request');
|
|
26
29
|
return this.handleWithCors({
|
|
27
30
|
statusCode: 200,
|
|
28
|
-
body: JSON.stringify(''),
|
|
31
|
+
body: JSON.stringify(''), // This produces '""'
|
|
29
32
|
}, event);
|
|
30
33
|
}
|
|
31
34
|
}
|
package/dist/corsHandler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"corsHandler.js","sourceRoot":"","sources":["../src/corsHandler.ts"],"names":[],"mappings":";;;AAEA,MAAa,WAAW;
|
|
1
|
+
{"version":3,"file":"corsHandler.js","sourceRoot":"","sources":["../src/corsHandler.ts"],"names":[],"mappings":";;;AAEA,MAAa,WAAW;IAGpB;QACI,IAAI,CAAC,cAAc,GAAG,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,CAAC;IAC1E,CAAC;IAEO,eAAe,CAAC,KAA2B;QAC/C,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAClE,OAAO,MAAM,CAAC;IAClB,CAAC;IAEM,cAAc,CACjB,QAA+B,EAC/B,KAA2B;QAE3B,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAC3C,MAAM,SAAS,GAAG,CAAC,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;QAErE,MAAM,aAAa,GAAW,CAAC,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAW,CAAC;QAEhG,OAAO;YACH,GAAG,QAAQ;YACX,OAAO,EAAE;gBACL,GAAG,CAAC,QAAQ,CAAC,OAAO,IAAI,EAAE,CAAC;gBAC3B,6BAA6B,EAAE,aAAa;gBAC5C,8BAA8B,EAAE,6BAA6B;gBAC7D,8BAA8B,EAAE,6BAA6B;gBAC7D,kCAAkC,EAAE,MAAM;aAC7C;SACJ,CAAC;IACN,CAAC;IAEM,mBAAmB,CAAC,KAA2B;QACpD,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,cAAc,CAAC;YACvB,UAAU,EAAE,GAAG;YACf,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,EAAG,qBAAqB;SACnD,EAAE,KAAK,CAAC,CAAC;IACd,CAAC;CAEF;AAzCD,kCAyCC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dromanis.finora.functions.common",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"build": "tsc",
|
|
12
12
|
"clean": "rm -rf dist",
|
|
13
13
|
"test": "jest --config jest.config.js",
|
|
14
|
-
"prepare": "husky install"
|
|
14
|
+
"prepare": "husky install",
|
|
15
|
+
"prepublishOnly": "npm run test && npm run clean && npm run build"
|
|
15
16
|
},
|
|
16
17
|
"keywords": [],
|
|
17
18
|
"author": "",
|