@studyportals/cors 2.7.0 → 2.8.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.
- package/index.d.ts +2 -2
- package/index.js +18 -18
- package/package.json +38 -38
- package/src/domain/allowed-domain-reg-ex-list.d.ts +10 -10
- package/src/domain/allowed-domain-reg-ex-list.js +30 -29
- package/src/domain/allowed-explicit-domains-rules.d.ts +42 -42
- package/src/domain/allowed-explicit-domains-rules.js +46 -46
- package/src/domain/cors.d.ts +16 -16
- package/src/domain/cors.js +37 -37
- package/src/domain/enums/environment.d.ts +4 -4
- package/src/domain/enums/environment.js +8 -8
- package/src/domain/enums/index.d.ts +2 -2
- package/src/domain/enums/index.js +18 -18
- package/src/domain/enums/scope.d.ts +4 -4
- package/src/domain/enums/scope.js +8 -8
- package/src/domain/index.d.ts +3 -3
- package/src/domain/index.js +19 -19
- package/src/implementations/express-middleware.d.ts +5 -5
- package/src/implementations/express-middleware.js +27 -27
- package/src/implementations/index.d.ts +3 -3
- package/src/implementations/index.js +19 -19
- package/src/implementations/options.d.ts +8 -8
- package/src/implementations/options.js +49 -49
- package/src/implementations/s3-rules.d.ts +5 -5
- package/src/implementations/s3-rules.js +12 -12
package/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './src/domain';
|
|
2
|
-
export * from './src/implementations';
|
|
1
|
+
export * from './src/domain';
|
|
2
|
+
export * from './src/implementations';
|
package/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./src/domain"), exports);
|
|
18
|
-
__exportStar(require("./src/implementations"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./src/domain"), exports);
|
|
18
|
+
__exportStar(require("./src/implementations"), exports);
|
package/package.json
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@studyportals/cors",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "bin/index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "mocha test/**/*.test.ts",
|
|
8
|
-
"test:watch": "mocha -w --reporter min test/**/*.test.ts",
|
|
9
|
-
"deploy-patch": "npm version patch && npm run deploy",
|
|
10
|
-
"deploy-minor": "npm version minor && npm run deploy",
|
|
11
|
-
"deploy-major": "npm version major && npm run deploy",
|
|
12
|
-
"prepare-deployment": "cp package.json bin/package.json",
|
|
13
|
-
"deploy": "npm run build && npm run prepare-deployment && npm publish ./bin",
|
|
14
|
-
"build": "rm -rf bin && tsc && rm -rf bin/test",
|
|
15
|
-
"lint": "tslint 'src/**/*.ts'",
|
|
16
|
-
"lint-fix": "tslint --fix 'src/**/*.ts'",
|
|
17
|
-
"test:coverage": "nyc mocha test/**/*.test.ts"
|
|
18
|
-
},
|
|
19
|
-
"private": false,
|
|
20
|
-
"author": "SP - Samurai Pizza Cats",
|
|
21
|
-
"license": "BSD3",
|
|
22
|
-
"dependencies": {
|
|
23
|
-
"@types/express": "^4.17.3"
|
|
24
|
-
},
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"@types/chai": "^4.1.7",
|
|
27
|
-
"@types/node": "^10.12.15",
|
|
28
|
-
"chai": "^4.2.0",
|
|
29
|
-
"mocha": "^5.2.0",
|
|
30
|
-
"mocha-typescript": "1.1.12",
|
|
31
|
-
"nyc": "^13.3.0",
|
|
32
|
-
"ts-loader": "^2.3.7",
|
|
33
|
-
"ts-node": "^7.0.1",
|
|
34
|
-
"tslint": "^5.11.0",
|
|
35
|
-
"typemoq": "^2.1.0",
|
|
36
|
-
"typescript": "^4.8.4"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@studyportals/cors",
|
|
3
|
+
"version": "2.8.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "bin/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "mocha test/**/*.test.ts",
|
|
8
|
+
"test:watch": "mocha -w --reporter min test/**/*.test.ts",
|
|
9
|
+
"deploy-patch": "npm version patch && npm run deploy",
|
|
10
|
+
"deploy-minor": "npm version minor && npm run deploy",
|
|
11
|
+
"deploy-major": "npm version major && npm run deploy",
|
|
12
|
+
"prepare-deployment": "cp package.json bin/package.json",
|
|
13
|
+
"deploy": "npm run build && npm run prepare-deployment && npm publish ./bin",
|
|
14
|
+
"build": "rm -rf bin && tsc && rm -rf bin/test",
|
|
15
|
+
"lint": "tslint 'src/**/*.ts'",
|
|
16
|
+
"lint-fix": "tslint --fix 'src/**/*.ts'",
|
|
17
|
+
"test:coverage": "nyc mocha test/**/*.test.ts"
|
|
18
|
+
},
|
|
19
|
+
"private": false,
|
|
20
|
+
"author": "SP - Samurai Pizza Cats",
|
|
21
|
+
"license": "BSD3",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@types/express": "^4.17.3"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/chai": "^4.1.7",
|
|
27
|
+
"@types/node": "^10.12.15",
|
|
28
|
+
"chai": "^4.2.0",
|
|
29
|
+
"mocha": "^5.2.0",
|
|
30
|
+
"mocha-typescript": "1.1.12",
|
|
31
|
+
"nyc": "^13.3.0",
|
|
32
|
+
"ts-loader": "^2.3.7",
|
|
33
|
+
"ts-node": "^7.0.1",
|
|
34
|
+
"tslint": "^5.11.0",
|
|
35
|
+
"typemoq": "^2.1.0",
|
|
36
|
+
"typescript": "^4.8.4"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export declare const AllowedDomainRegExList: {
|
|
2
|
-
0: {
|
|
3
|
-
0: RegExp[];
|
|
4
|
-
1: RegExp[];
|
|
5
|
-
};
|
|
6
|
-
1: {
|
|
7
|
-
0: RegExp[];
|
|
8
|
-
1: RegExp[];
|
|
9
|
-
};
|
|
10
|
-
};
|
|
1
|
+
export declare const AllowedDomainRegExList: {
|
|
2
|
+
0: {
|
|
3
|
+
0: RegExp[];
|
|
4
|
+
1: RegExp[];
|
|
5
|
+
};
|
|
6
|
+
1: {
|
|
7
|
+
0: RegExp[];
|
|
8
|
+
1: RegExp[];
|
|
9
|
+
};
|
|
10
|
+
};
|
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AllowedDomainRegExList = void 0;
|
|
4
|
-
const environment_1 = require("./enums/environment");
|
|
5
|
-
const scope_1 = require("./enums/scope");
|
|
6
|
-
exports.AllowedDomainRegExList = {
|
|
7
|
-
[scope_1.Scope.Student]: {
|
|
8
|
-
[environment_1.Environment.Production]: [
|
|
9
|
-
/^https?:\/\/(www(?:\.dev)?|cypress\.rc|rc|beta|[0-9]{4,16}(?:-bob)?\.rc)\.mastersportal\.(com|fyi)(?::3030)?$/,
|
|
10
|
-
/^https?:\/\/(www(?:\.dev)?|cypress\.rc|rc|beta|[0-9]{4,16}(?:-bob)?\.rc)\.bachelorsportal\.(com|fyi)(?::3030)?$/,
|
|
11
|
-
/^https?:\/\/(www(?:\.dev)?|cypress\.rc|rc|beta|[0-9]{4,16}(?:-bob)?\.rc)\.phdportal\.(com|fyi)(?::3030)?$/,
|
|
12
|
-
/^https?:\/\/(www(?:\.dev)?|cypress\.rc|rc|beta|[0-9]{4,16}(?:-bob)?\.rc)\.preparationcoursesportal\.(com|fyi)(?::3030)?$/,
|
|
13
|
-
/^https?:\/\/(www(?:\.dev)?|cypress\.rc|rc|beta|[0-9]{4,16}(?:-bob)?\.rc)\.distancelearningportal\.(com|fyi)(?::3030)?$/,
|
|
14
|
-
/^https?:\/\/(www(?:\.dev)?|cypress\.rc|rc|beta|[0-9]{4,16}(?:-bob)?\.rc)\.shortcoursesportal\.(com|fyi)(?::3030)?$/,
|
|
15
|
-
/^https?:\/\/(www.)?admissiontestportal.com?$/,
|
|
16
|
-
/^https?:\/\/studentemailing\.prtl\.co$/,
|
|
17
|
-
/^https?:\/\/scholarship\.mastersportal\.com$/,
|
|
18
|
-
/^https?:\/\/students\.mastersportal\.com$/,
|
|
19
|
-
/^https?:\/\/search-page\.prtl\.co$/,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
[environment_1.Environment.
|
|
28
|
-
|
|
29
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AllowedDomainRegExList = void 0;
|
|
4
|
+
const environment_1 = require("./enums/environment");
|
|
5
|
+
const scope_1 = require("./enums/scope");
|
|
6
|
+
exports.AllowedDomainRegExList = {
|
|
7
|
+
[scope_1.Scope.Student]: {
|
|
8
|
+
[environment_1.Environment.Production]: [
|
|
9
|
+
/^https?:\/\/(www(?:\.dev)?|cypress\.rc|rc|beta|[0-9]{4,16}(?:-bob)?\.rc)\.mastersportal\.(com|fyi)(?::3030)?$/,
|
|
10
|
+
/^https?:\/\/(www(?:\.dev)?|cypress\.rc|rc|beta|[0-9]{4,16}(?:-bob)?\.rc)\.bachelorsportal\.(com|fyi)(?::3030)?$/,
|
|
11
|
+
/^https?:\/\/(www(?:\.dev)?|cypress\.rc|rc|beta|[0-9]{4,16}(?:-bob)?\.rc)\.phdportal\.(com|fyi)(?::3030)?$/,
|
|
12
|
+
/^https?:\/\/(www(?:\.dev)?|cypress\.rc|rc|beta|[0-9]{4,16}(?:-bob)?\.rc)\.preparationcoursesportal\.(com|fyi)(?::3030)?$/,
|
|
13
|
+
/^https?:\/\/(www(?:\.dev)?|cypress\.rc|rc|beta|[0-9]{4,16}(?:-bob)?\.rc)\.distancelearningportal\.(com|fyi)(?::3030)?$/,
|
|
14
|
+
/^https?:\/\/(www(?:\.dev)?|cypress\.rc|rc|beta|[0-9]{4,16}(?:-bob)?\.rc)\.shortcoursesportal\.(com|fyi)(?::3030)?$/,
|
|
15
|
+
/^https?:\/\/(www.)?admissiontestportal.com?$/,
|
|
16
|
+
/^https?:\/\/studentemailing\.prtl\.co$/,
|
|
17
|
+
/^https?:\/\/scholarship\.mastersportal\.com$/,
|
|
18
|
+
/^https?:\/\/students\.mastersportal\.com$/,
|
|
19
|
+
/^https?:\/\/search-page\.prtl\.co$/,
|
|
20
|
+
/^https?:\/\/reviews\.studyportals\.com$/,
|
|
21
|
+
],
|
|
22
|
+
[environment_1.Environment.Testing]: [
|
|
23
|
+
/(.*?)/,
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
[scope_1.Scope.UniAdmin]: {
|
|
27
|
+
[environment_1.Environment.Production]: [/(.*?)/],
|
|
28
|
+
[environment_1.Environment.Testing]: [/(.*?)/],
|
|
29
|
+
},
|
|
30
|
+
};
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
export declare type AllowedExplicitDomainsRulesType = typeof AllowedExplicitDomainsRules;
|
|
2
|
-
export declare type CorsRule = {
|
|
3
|
-
allowedOrigins: string[];
|
|
4
|
-
allowedMethods: string[];
|
|
5
|
-
allowedHeaders: string[];
|
|
6
|
-
exposedHeaders: string[];
|
|
7
|
-
maxAge: number;
|
|
8
|
-
};
|
|
9
|
-
export declare const AllowedExplicitDomainsRules: {
|
|
10
|
-
0: {
|
|
11
|
-
0: {
|
|
12
|
-
allowedOrigins: string[];
|
|
13
|
-
allowedHeaders: string[];
|
|
14
|
-
allowedMethods: string[];
|
|
15
|
-
exposedHeaders: never[];
|
|
16
|
-
maxAge: number;
|
|
17
|
-
};
|
|
18
|
-
1: {
|
|
19
|
-
allowedOrigins: string[];
|
|
20
|
-
allowedMethods: string[];
|
|
21
|
-
allowedHeaders: string[];
|
|
22
|
-
exposedHeaders: never[];
|
|
23
|
-
maxAge: number;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
1: {
|
|
27
|
-
0: {
|
|
28
|
-
allowedOrigins: string[];
|
|
29
|
-
allowedHeaders: string[];
|
|
30
|
-
allowedMethods: string[];
|
|
31
|
-
exposedHeaders: never[];
|
|
32
|
-
maxAge: number;
|
|
33
|
-
};
|
|
34
|
-
1: {
|
|
35
|
-
allowedOrigins: string[];
|
|
36
|
-
allowedMethods: string[];
|
|
37
|
-
allowedHeaders: string[];
|
|
38
|
-
exposedHeaders: never[];
|
|
39
|
-
maxAge: number;
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
};
|
|
1
|
+
export declare type AllowedExplicitDomainsRulesType = typeof AllowedExplicitDomainsRules;
|
|
2
|
+
export declare type CorsRule = {
|
|
3
|
+
allowedOrigins: string[];
|
|
4
|
+
allowedMethods: string[];
|
|
5
|
+
allowedHeaders: string[];
|
|
6
|
+
exposedHeaders: string[];
|
|
7
|
+
maxAge: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const AllowedExplicitDomainsRules: {
|
|
10
|
+
0: {
|
|
11
|
+
0: {
|
|
12
|
+
allowedOrigins: string[];
|
|
13
|
+
allowedHeaders: string[];
|
|
14
|
+
allowedMethods: string[];
|
|
15
|
+
exposedHeaders: never[];
|
|
16
|
+
maxAge: number;
|
|
17
|
+
};
|
|
18
|
+
1: {
|
|
19
|
+
allowedOrigins: string[];
|
|
20
|
+
allowedMethods: string[];
|
|
21
|
+
allowedHeaders: string[];
|
|
22
|
+
exposedHeaders: never[];
|
|
23
|
+
maxAge: number;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
1: {
|
|
27
|
+
0: {
|
|
28
|
+
allowedOrigins: string[];
|
|
29
|
+
allowedHeaders: string[];
|
|
30
|
+
allowedMethods: string[];
|
|
31
|
+
exposedHeaders: never[];
|
|
32
|
+
maxAge: number;
|
|
33
|
+
};
|
|
34
|
+
1: {
|
|
35
|
+
allowedOrigins: string[];
|
|
36
|
+
allowedMethods: string[];
|
|
37
|
+
allowedHeaders: string[];
|
|
38
|
+
exposedHeaders: never[];
|
|
39
|
+
maxAge: number;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
};
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AllowedExplicitDomainsRules = void 0;
|
|
4
|
-
const environment_1 = require("./enums/environment");
|
|
5
|
-
const scope_1 = require("./enums/scope");
|
|
6
|
-
exports.AllowedExplicitDomainsRules = {
|
|
7
|
-
[scope_1.Scope.Student]: {
|
|
8
|
-
[environment_1.Environment.Production]: {
|
|
9
|
-
allowedOrigins: ["*.mastersportal.com", "*.bachelorsportal.com", "*.shortcoursesportal.com",
|
|
10
|
-
"*.distancelearningportal.com", "*.preparationcoursesportal.com", "*.phdportal.com",
|
|
11
|
-
"*.prtl.co", "*.rc.mastersportal.fyi", "*.rc.bachelorsportal.fyi", "*.rc.shortcoursesportal.fyi",
|
|
12
|
-
"*.rc.distancelearningportal.fyi", "*.rc.preparationcoursesportal.fyi", "*.rc.phdportal.fyi",
|
|
13
|
-
"*.admissiontestportal.com", "https://admissiontestportal.com"],
|
|
14
|
-
allowedHeaders: ["Authorization"],
|
|
15
|
-
allowedMethods: ["GET"],
|
|
16
|
-
exposedHeaders: [],
|
|
17
|
-
maxAge: 3000
|
|
18
|
-
},
|
|
19
|
-
[environment_1.Environment.Testing]: {
|
|
20
|
-
allowedOrigins: ["*"],
|
|
21
|
-
allowedMethods: ["GET"],
|
|
22
|
-
allowedHeaders: ["Authorization"],
|
|
23
|
-
exposedHeaders: [],
|
|
24
|
-
maxAge: 3000
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
[scope_1.Scope.UniAdmin]: {
|
|
28
|
-
[environment_1.Environment.Production]: {
|
|
29
|
-
allowedOrigins: ["*.studyportals.eu"],
|
|
30
|
-
allowedHeaders: ["Authorization"],
|
|
31
|
-
allowedMethods: ["GET", "POST"],
|
|
32
|
-
exposedHeaders: [],
|
|
33
|
-
maxAge: 3000
|
|
34
|
-
},
|
|
35
|
-
[environment_1.Environment.Testing]: {
|
|
36
|
-
allowedOrigins: ["*-uniadmin.prtl.fyi",
|
|
37
|
-
"*.administration.tst.studyportals.eu", "administration.tst.studyportals.eu",
|
|
38
|
-
"https://administration.dev.studyportals.eu:*",
|
|
39
|
-
"*-uniadmin.studyportals.eu"],
|
|
40
|
-
allowedMethods: ["GET"],
|
|
41
|
-
allowedHeaders: ["*"],
|
|
42
|
-
exposedHeaders: [],
|
|
43
|
-
maxAge: 3000
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AllowedExplicitDomainsRules = void 0;
|
|
4
|
+
const environment_1 = require("./enums/environment");
|
|
5
|
+
const scope_1 = require("./enums/scope");
|
|
6
|
+
exports.AllowedExplicitDomainsRules = {
|
|
7
|
+
[scope_1.Scope.Student]: {
|
|
8
|
+
[environment_1.Environment.Production]: {
|
|
9
|
+
allowedOrigins: ["*.mastersportal.com", "*.bachelorsportal.com", "*.shortcoursesportal.com",
|
|
10
|
+
"*.distancelearningportal.com", "*.preparationcoursesportal.com", "*.phdportal.com",
|
|
11
|
+
"*.prtl.co", "*.rc.mastersportal.fyi", "*.rc.bachelorsportal.fyi", "*.rc.shortcoursesportal.fyi",
|
|
12
|
+
"*.rc.distancelearningportal.fyi", "*.rc.preparationcoursesportal.fyi", "*.rc.phdportal.fyi",
|
|
13
|
+
"*.admissiontestportal.com", "https://admissiontestportal.com", "*.studyportals.com"],
|
|
14
|
+
allowedHeaders: ["Authorization"],
|
|
15
|
+
allowedMethods: ["GET"],
|
|
16
|
+
exposedHeaders: [],
|
|
17
|
+
maxAge: 3000
|
|
18
|
+
},
|
|
19
|
+
[environment_1.Environment.Testing]: {
|
|
20
|
+
allowedOrigins: ["*"],
|
|
21
|
+
allowedMethods: ["GET"],
|
|
22
|
+
allowedHeaders: ["Authorization"],
|
|
23
|
+
exposedHeaders: [],
|
|
24
|
+
maxAge: 3000
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
[scope_1.Scope.UniAdmin]: {
|
|
28
|
+
[environment_1.Environment.Production]: {
|
|
29
|
+
allowedOrigins: ["*.studyportals.eu"],
|
|
30
|
+
allowedHeaders: ["Authorization"],
|
|
31
|
+
allowedMethods: ["GET", "POST"],
|
|
32
|
+
exposedHeaders: [],
|
|
33
|
+
maxAge: 3000
|
|
34
|
+
},
|
|
35
|
+
[environment_1.Environment.Testing]: {
|
|
36
|
+
allowedOrigins: ["*-uniadmin.prtl.fyi",
|
|
37
|
+
"*.administration.tst.studyportals.eu", "administration.tst.studyportals.eu",
|
|
38
|
+
"https://administration.dev.studyportals.eu:*",
|
|
39
|
+
"*-uniadmin.studyportals.eu"],
|
|
40
|
+
allowedMethods: ["GET"],
|
|
41
|
+
allowedHeaders: ["*"],
|
|
42
|
+
exposedHeaders: [],
|
|
43
|
+
maxAge: 3000
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
package/src/domain/cors.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { CorsRule } from './allowed-explicit-domains-rules';
|
|
2
|
-
import { Environment } from './enums/environment';
|
|
3
|
-
import { Scope } from './enums/scope';
|
|
4
|
-
export declare class CORS {
|
|
5
|
-
private regExes;
|
|
6
|
-
private s3Rules;
|
|
7
|
-
constructor(scope: Scope, environment?: Environment);
|
|
8
|
-
/**
|
|
9
|
-
* isValidDomain
|
|
10
|
-
*/
|
|
11
|
-
isValidDomain(domain: string): Promise<boolean>;
|
|
12
|
-
/**
|
|
13
|
-
* getIamRules
|
|
14
|
-
*/
|
|
15
|
-
getS3Rules(): CorsRule[];
|
|
16
|
-
}
|
|
1
|
+
import { CorsRule } from './allowed-explicit-domains-rules';
|
|
2
|
+
import { Environment } from './enums/environment';
|
|
3
|
+
import { Scope } from './enums/scope';
|
|
4
|
+
export declare class CORS {
|
|
5
|
+
private regExes;
|
|
6
|
+
private s3Rules;
|
|
7
|
+
constructor(scope: Scope, environment?: Environment);
|
|
8
|
+
/**
|
|
9
|
+
* isValidDomain
|
|
10
|
+
*/
|
|
11
|
+
isValidDomain(domain: string): Promise<boolean>;
|
|
12
|
+
/**
|
|
13
|
+
* getIamRules
|
|
14
|
+
*/
|
|
15
|
+
getS3Rules(): CorsRule[];
|
|
16
|
+
}
|
package/src/domain/cors.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.CORS = void 0;
|
|
13
|
-
const allowed_domain_reg_ex_list_1 = require("./allowed-domain-reg-ex-list");
|
|
14
|
-
const allowed_explicit_domains_rules_1 = require("./allowed-explicit-domains-rules");
|
|
15
|
-
const environment_1 = require("./enums/environment");
|
|
16
|
-
class CORS {
|
|
17
|
-
constructor(scope, environment = environment_1.Environment.Production) {
|
|
18
|
-
this.regExes = allowed_domain_reg_ex_list_1.AllowedDomainRegExList[scope][environment];
|
|
19
|
-
this.s3Rules = [allowed_explicit_domains_rules_1.AllowedExplicitDomainsRules[scope][environment]];
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* isValidDomain
|
|
23
|
-
*/
|
|
24
|
-
isValidDomain(domain) {
|
|
25
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
const hasMatch = this.regExes.filter((regex) => domain.match(regex) !== null);
|
|
27
|
-
return (hasMatch.length !== 0);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* getIamRules
|
|
32
|
-
*/
|
|
33
|
-
getS3Rules() {
|
|
34
|
-
return this.s3Rules;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.CORS = CORS;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CORS = void 0;
|
|
13
|
+
const allowed_domain_reg_ex_list_1 = require("./allowed-domain-reg-ex-list");
|
|
14
|
+
const allowed_explicit_domains_rules_1 = require("./allowed-explicit-domains-rules");
|
|
15
|
+
const environment_1 = require("./enums/environment");
|
|
16
|
+
class CORS {
|
|
17
|
+
constructor(scope, environment = environment_1.Environment.Production) {
|
|
18
|
+
this.regExes = allowed_domain_reg_ex_list_1.AllowedDomainRegExList[scope][environment];
|
|
19
|
+
this.s3Rules = [allowed_explicit_domains_rules_1.AllowedExplicitDomainsRules[scope][environment]];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* isValidDomain
|
|
23
|
+
*/
|
|
24
|
+
isValidDomain(domain) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const hasMatch = this.regExes.filter((regex) => domain.match(regex) !== null);
|
|
27
|
+
return (hasMatch.length !== 0);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* getIamRules
|
|
32
|
+
*/
|
|
33
|
+
getS3Rules() {
|
|
34
|
+
return this.s3Rules;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.CORS = CORS;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare enum Environment {
|
|
2
|
-
Production = 0,
|
|
3
|
-
Testing = 1
|
|
4
|
-
}
|
|
1
|
+
export declare enum Environment {
|
|
2
|
+
Production = 0,
|
|
3
|
+
Testing = 1
|
|
4
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Environment = void 0;
|
|
4
|
-
var Environment;
|
|
5
|
-
(function (Environment) {
|
|
6
|
-
Environment[Environment["Production"] = 0] = "Production";
|
|
7
|
-
Environment[Environment["Testing"] = 1] = "Testing";
|
|
8
|
-
})(Environment = exports.Environment || (exports.Environment = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Environment = void 0;
|
|
4
|
+
var Environment;
|
|
5
|
+
(function (Environment) {
|
|
6
|
+
Environment[Environment["Production"] = 0] = "Production";
|
|
7
|
+
Environment[Environment["Testing"] = 1] = "Testing";
|
|
8
|
+
})(Environment = exports.Environment || (exports.Environment = {}));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './environment';
|
|
2
|
-
export * from './scope';
|
|
1
|
+
export * from './environment';
|
|
2
|
+
export * from './scope';
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./environment"), exports);
|
|
18
|
-
__exportStar(require("./scope"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./environment"), exports);
|
|
18
|
+
__exportStar(require("./scope"), exports);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare enum Scope {
|
|
2
|
-
Student = 0,
|
|
3
|
-
UniAdmin = 1
|
|
4
|
-
}
|
|
1
|
+
export declare enum Scope {
|
|
2
|
+
Student = 0,
|
|
3
|
+
UniAdmin = 1
|
|
4
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Scope = void 0;
|
|
4
|
-
var Scope;
|
|
5
|
-
(function (Scope) {
|
|
6
|
-
Scope[Scope["Student"] = 0] = "Student";
|
|
7
|
-
Scope[Scope["UniAdmin"] = 1] = "UniAdmin";
|
|
8
|
-
})(Scope = exports.Scope || (exports.Scope = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Scope = void 0;
|
|
4
|
+
var Scope;
|
|
5
|
+
(function (Scope) {
|
|
6
|
+
Scope[Scope["Student"] = 0] = "Student";
|
|
7
|
+
Scope[Scope["UniAdmin"] = 1] = "UniAdmin";
|
|
8
|
+
})(Scope = exports.Scope || (exports.Scope = {}));
|
package/src/domain/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './cors';
|
|
2
|
-
export * from './allowed-domain-reg-ex-list';
|
|
3
|
-
export * from './enums';
|
|
1
|
+
export * from './cors';
|
|
2
|
+
export * from './allowed-domain-reg-ex-list';
|
|
3
|
+
export * from './enums';
|
package/src/domain/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./cors"), exports);
|
|
18
|
-
__exportStar(require("./allowed-domain-reg-ex-list"), exports);
|
|
19
|
-
__exportStar(require("./enums"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./cors"), exports);
|
|
18
|
+
__exportStar(require("./allowed-domain-reg-ex-list"), exports);
|
|
19
|
+
__exportStar(require("./enums"), exports);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RequestHandler } from 'express';
|
|
2
|
-
import { Environment, Scope } from '../domain/enums';
|
|
3
|
-
export declare class ExpressMiddleware {
|
|
4
|
-
static getMiddleWare(scope: Scope, environment?: Environment): RequestHandler;
|
|
5
|
-
}
|
|
1
|
+
import { RequestHandler } from 'express';
|
|
2
|
+
import { Environment, Scope } from '../domain/enums';
|
|
3
|
+
export declare class ExpressMiddleware {
|
|
4
|
+
static getMiddleWare(scope: Scope, environment?: Environment): RequestHandler;
|
|
5
|
+
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.ExpressMiddleware = void 0;
|
|
13
|
-
const domain_1 = require("../domain");
|
|
14
|
-
const enums_1 = require("../domain/enums");
|
|
15
|
-
class ExpressMiddleware {
|
|
16
|
-
static getMiddleWare(scope, environment = enums_1.Environment.Production) {
|
|
17
|
-
const cors = new domain_1.CORS(scope, environment);
|
|
18
|
-
return (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
const origin = req.get('origin') || '';
|
|
20
|
-
if (yield cors.isValidDomain(origin)) {
|
|
21
|
-
res.header('Access-Control-Allow-Origin', origin);
|
|
22
|
-
}
|
|
23
|
-
next();
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.ExpressMiddleware = ExpressMiddleware;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ExpressMiddleware = void 0;
|
|
13
|
+
const domain_1 = require("../domain");
|
|
14
|
+
const enums_1 = require("../domain/enums");
|
|
15
|
+
class ExpressMiddleware {
|
|
16
|
+
static getMiddleWare(scope, environment = enums_1.Environment.Production) {
|
|
17
|
+
const cors = new domain_1.CORS(scope, environment);
|
|
18
|
+
return (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const origin = req.get('origin') || '';
|
|
20
|
+
if (yield cors.isValidDomain(origin)) {
|
|
21
|
+
res.header('Access-Control-Allow-Origin', origin);
|
|
22
|
+
}
|
|
23
|
+
next();
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.ExpressMiddleware = ExpressMiddleware;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './options';
|
|
2
|
-
export * from './express-middleware';
|
|
3
|
-
export * from './s3-rules';
|
|
1
|
+
export * from './options';
|
|
2
|
+
export * from './express-middleware';
|
|
3
|
+
export * from './s3-rules';
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./options"), exports);
|
|
18
|
-
__exportStar(require("./express-middleware"), exports);
|
|
19
|
-
__exportStar(require("./s3-rules"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./options"), exports);
|
|
18
|
+
__exportStar(require("./express-middleware"), exports);
|
|
19
|
+
__exportStar(require("./s3-rules"), exports);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Environment, Scope } from '../domain/enums';
|
|
2
|
-
export declare class OptionsLambda {
|
|
3
|
-
private cors;
|
|
4
|
-
constructor(scope: Scope, environment?: Environment);
|
|
5
|
-
getLowercasedHeaders(event: any): any;
|
|
6
|
-
getOrigin(event: any): string;
|
|
7
|
-
getHandler(): (event: any) => Promise<any>;
|
|
8
|
-
}
|
|
1
|
+
import { Environment, Scope } from '../domain/enums';
|
|
2
|
+
export declare class OptionsLambda {
|
|
3
|
+
private cors;
|
|
4
|
+
constructor(scope: Scope, environment?: Environment);
|
|
5
|
+
getLowercasedHeaders(event: any): any;
|
|
6
|
+
getOrigin(event: any): string;
|
|
7
|
+
getHandler(): (event: any) => Promise<any>;
|
|
8
|
+
}
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.OptionsLambda = void 0;
|
|
13
|
-
const domain_1 = require("../domain");
|
|
14
|
-
const enums_1 = require("../domain/enums");
|
|
15
|
-
class OptionsLambda {
|
|
16
|
-
constructor(scope, environment = enums_1.Environment.Production) {
|
|
17
|
-
this.cors = new domain_1.CORS(scope, environment);
|
|
18
|
-
}
|
|
19
|
-
getLowercasedHeaders(event) {
|
|
20
|
-
const headers = {};
|
|
21
|
-
Object.keys(event.headers).forEach((key) => {
|
|
22
|
-
headers[key.toLowerCase()] = event.headers[key];
|
|
23
|
-
});
|
|
24
|
-
return headers;
|
|
25
|
-
}
|
|
26
|
-
getOrigin(event) {
|
|
27
|
-
const headers = this.getLowercasedHeaders(event);
|
|
28
|
-
return headers['origin'];
|
|
29
|
-
}
|
|
30
|
-
getHandler() {
|
|
31
|
-
return (event) => __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
const origin = this.getOrigin(event);
|
|
33
|
-
const headers = {
|
|
34
|
-
'Cache-Control': 'max-age=600, s-maxage=600, proxy-revalidate',
|
|
35
|
-
};
|
|
36
|
-
if (yield this.cors.isValidDomain(origin)) {
|
|
37
|
-
headers['Access-Control-Allow-Origin'] = origin;
|
|
38
|
-
headers['Access-Control-Allow-Headers'] = 'authorization, x-api-key, content-type';
|
|
39
|
-
headers['Access-Control-Allow-Methods'] = 'GET, POST, DELETE, PATCH, HEAD, PUT, OPTIONS';
|
|
40
|
-
headers['Access-Control-Max-Age'] = '600';
|
|
41
|
-
}
|
|
42
|
-
return {
|
|
43
|
-
statusCode: 200,
|
|
44
|
-
headers,
|
|
45
|
-
};
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.OptionsLambda = OptionsLambda;
|
|
1
|
+
'use strict';
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.OptionsLambda = void 0;
|
|
13
|
+
const domain_1 = require("../domain");
|
|
14
|
+
const enums_1 = require("../domain/enums");
|
|
15
|
+
class OptionsLambda {
|
|
16
|
+
constructor(scope, environment = enums_1.Environment.Production) {
|
|
17
|
+
this.cors = new domain_1.CORS(scope, environment);
|
|
18
|
+
}
|
|
19
|
+
getLowercasedHeaders(event) {
|
|
20
|
+
const headers = {};
|
|
21
|
+
Object.keys(event.headers).forEach((key) => {
|
|
22
|
+
headers[key.toLowerCase()] = event.headers[key];
|
|
23
|
+
});
|
|
24
|
+
return headers;
|
|
25
|
+
}
|
|
26
|
+
getOrigin(event) {
|
|
27
|
+
const headers = this.getLowercasedHeaders(event);
|
|
28
|
+
return headers['origin'];
|
|
29
|
+
}
|
|
30
|
+
getHandler() {
|
|
31
|
+
return (event) => __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const origin = this.getOrigin(event);
|
|
33
|
+
const headers = {
|
|
34
|
+
'Cache-Control': 'max-age=600, s-maxage=600, proxy-revalidate',
|
|
35
|
+
};
|
|
36
|
+
if (yield this.cors.isValidDomain(origin)) {
|
|
37
|
+
headers['Access-Control-Allow-Origin'] = origin;
|
|
38
|
+
headers['Access-Control-Allow-Headers'] = 'authorization, x-api-key, content-type';
|
|
39
|
+
headers['Access-Control-Allow-Methods'] = 'GET, POST, DELETE, PATCH, HEAD, PUT, OPTIONS';
|
|
40
|
+
headers['Access-Control-Max-Age'] = '600';
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
statusCode: 200,
|
|
44
|
+
headers,
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.OptionsLambda = OptionsLambda;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CorsRule } from '../domain/allowed-explicit-domains-rules';
|
|
2
|
-
import { Environment, Scope } from '../domain/enums';
|
|
3
|
-
export declare class S3Rules {
|
|
4
|
-
static generate(scope: Scope, environment?: Environment): CorsRule[];
|
|
5
|
-
}
|
|
1
|
+
import { CorsRule } from '../domain/allowed-explicit-domains-rules';
|
|
2
|
+
import { Environment, Scope } from '../domain/enums';
|
|
3
|
+
export declare class S3Rules {
|
|
4
|
+
static generate(scope: Scope, environment?: Environment): CorsRule[];
|
|
5
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.S3Rules = void 0;
|
|
4
|
-
const domain_1 = require("../domain");
|
|
5
|
-
const enums_1 = require("../domain/enums");
|
|
6
|
-
class S3Rules {
|
|
7
|
-
static generate(scope, environment = enums_1.Environment.Production) {
|
|
8
|
-
const cors = new domain_1.CORS(scope, environment);
|
|
9
|
-
return cors.getS3Rules();
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
exports.S3Rules = S3Rules;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.S3Rules = void 0;
|
|
4
|
+
const domain_1 = require("../domain");
|
|
5
|
+
const enums_1 = require("../domain/enums");
|
|
6
|
+
class S3Rules {
|
|
7
|
+
static generate(scope, environment = enums_1.Environment.Production) {
|
|
8
|
+
const cors = new domain_1.CORS(scope, environment);
|
|
9
|
+
return cors.getS3Rules();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.S3Rules = S3Rules;
|