dromanis.finora.functions.common 3.0.1 → 3.0.3
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 +5 -3
- package/dist/corsHandler.d.ts.map +1 -1
- package/dist/corsHandler.js +14 -5
- package/dist/corsHandler.js.map +1 -1
- package/package.json +1 -1
package/dist/corsHandler.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { APIGatewayProxyResult } from 'aws-lambda';
|
|
1
|
+
import { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda';
|
|
2
2
|
export declare class corsHandler {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
private allowedOrigins;
|
|
4
|
+
private getOriginHeader;
|
|
5
|
+
handleWithCors(response: APIGatewayProxyResult, event: APIGatewayProxyEvent): APIGatewayProxyResult;
|
|
6
|
+
handleOptionsMethod(event: APIGatewayProxyEvent): APIGatewayProxyResult;
|
|
5
7
|
}
|
|
6
8
|
//# sourceMappingURL=corsHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"corsHandler.d.ts","sourceRoot":"","sources":["../src/corsHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;
|
|
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;IAEtB,OAAO,CAAC,cAAc,CAA4D;IAGlF,OAAO,CAAC,eAAe;IAIvB,cAAc,CAAC,QAAQ,EAAE,qBAAqB,EAAE,KAAK,EAAE,oBAAoB,GAAG,qBAAqB;IAgBnG,mBAAmB,CAAC,KAAK,EAAE,oBAAoB,GAAG,qBAAqB;CAMxE"}
|
package/dist/corsHandler.js
CHANGED
|
@@ -2,22 +2,31 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.corsHandler = void 0;
|
|
4
4
|
class corsHandler {
|
|
5
|
-
|
|
5
|
+
constructor() {
|
|
6
|
+
this.allowedOrigins = ['https://finora.dromanis.com', 'http://localhost:4050'];
|
|
7
|
+
}
|
|
8
|
+
getOriginHeader(event) {
|
|
9
|
+
return event.headers['origin'] || event.headers['Origin'];
|
|
10
|
+
}
|
|
11
|
+
handleWithCors(response, event) {
|
|
12
|
+
const origin = this.getOriginHeader(event);
|
|
13
|
+
const isAllowed = origin && this.allowedOrigins.includes(origin);
|
|
6
14
|
return {
|
|
7
15
|
...response,
|
|
8
16
|
headers: {
|
|
9
17
|
...(response.headers || {}),
|
|
10
|
-
'Access-Control-Allow-Origin': '*',
|
|
11
|
-
'Access-Control-Allow-Headers': '
|
|
18
|
+
'Access-Control-Allow-Origin': isAllowed ? origin : '*',
|
|
19
|
+
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
|
|
12
20
|
'Access-Control-Allow-Methods': 'GET,POST,PUT,DELETE,OPTIONS',
|
|
21
|
+
'Access-Control-Allow-Credentials': 'true',
|
|
13
22
|
},
|
|
14
23
|
};
|
|
15
24
|
}
|
|
16
|
-
handleOptionsMethod() {
|
|
25
|
+
handleOptionsMethod(event) {
|
|
17
26
|
return this.handleWithCors({
|
|
18
27
|
statusCode: 200,
|
|
19
28
|
body: JSON.stringify(''),
|
|
20
|
-
});
|
|
29
|
+
}, event);
|
|
21
30
|
}
|
|
22
31
|
}
|
|
23
32
|
exports.corsHandler = corsHandler;
|
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;IAAxB;QAEU,mBAAc,GAAG,CAAC,6BAA6B,EAAE,uBAAuB,CAAC,CAAC;IA6BpF,CAAC;IA1BS,eAAe,CAAC,KAA2B;QACjD,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC5D,CAAC;IAED,cAAc,CAAC,QAA+B,EAAE,KAA2B;QAEzE,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAC3C,MAAM,SAAS,GAAG,MAAM,IAAI,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACjE,OAAO;YACL,GAAG,QAAQ;YACX,OAAO,EAAE;gBACP,GAAG,CAAC,QAAQ,CAAC,OAAO,IAAI,EAAE,CAAC;gBAC3B,6BAA6B,EAAE,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG;gBACvD,8BAA8B,EAAE,6BAA6B;gBAC7D,8BAA8B,EAAE,6BAA6B;gBAC7D,kCAAkC,EAAE,MAAM;aAC3C;SACF,CAAC;IACJ,CAAC;IAED,mBAAmB,CAAC,KAA2B;QAC7C,OAAO,IAAI,CAAC,cAAc,CAAC;YACzB,UAAU,EAAE,GAAG;YACf,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;SACzB,EAAE,KAAK,CAAC,CAAC;IACZ,CAAC;CACF;AA/BD,kCA+BC"}
|