@churchapps/apihelper 0.0.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/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/auth/AuthenticatedUser.d.ts +17 -0
- package/dist/auth/AuthenticatedUser.d.ts.map +1 -0
- package/dist/auth/AuthenticatedUser.js +31 -0
- package/dist/auth/AuthenticatedUser.js.map +1 -0
- package/dist/auth/CustomAuthProvider.d.ts +7 -0
- package/dist/auth/CustomAuthProvider.d.ts.map +1 -0
- package/dist/auth/CustomAuthProvider.js +46 -0
- package/dist/auth/CustomAuthProvider.js.map +1 -0
- package/dist/auth/Principal.d.ts +9 -0
- package/dist/auth/Principal.d.ts.map +1 -0
- package/dist/auth/Principal.js +19 -0
- package/dist/auth/Principal.js.map +1 -0
- package/dist/auth/index.d.ts +4 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +10 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/controllers/CustomBaseController.d.ts +15 -0
- package/dist/controllers/CustomBaseController.d.ts.map +1 -0
- package/dist/controllers/CustomBaseController.js +83 -0
- package/dist/controllers/CustomBaseController.js.map +1 -0
- package/dist/controllers/ErrorController.d.ts +7 -0
- package/dist/controllers/ErrorController.d.ts.map +1 -0
- package/dist/controllers/ErrorController.js +63 -0
- package/dist/controllers/ErrorController.js.map +1 -0
- package/dist/controllers/index.d.ts +3 -0
- package/dist/controllers/index.d.ts.map +1 -0
- package/dist/controllers/index.js +8 -0
- package/dist/controllers/index.js.map +1 -0
- package/dist/helpers/AwsHelper.d.ts +13 -0
- package/dist/helpers/AwsHelper.d.ts.map +1 -0
- package/dist/helpers/AwsHelper.js +131 -0
- package/dist/helpers/AwsHelper.js.map +1 -0
- package/dist/helpers/BasePermissions.d.ts +31 -0
- package/dist/helpers/BasePermissions.d.ts.map +1 -0
- package/dist/helpers/BasePermissions.js +20 -0
- package/dist/helpers/BasePermissions.js.map +1 -0
- package/dist/helpers/DB.d.ts +8 -0
- package/dist/helpers/DB.d.ts.map +1 -0
- package/dist/helpers/DB.js +72 -0
- package/dist/helpers/DB.js.map +1 -0
- package/dist/helpers/DBCreator.d.ts +6 -0
- package/dist/helpers/DBCreator.d.ts.map +1 -0
- package/dist/helpers/DBCreator.js +56 -0
- package/dist/helpers/DBCreator.js.map +1 -0
- package/dist/helpers/EmailHelper.d.ts +7 -0
- package/dist/helpers/EmailHelper.d.ts.map +1 -0
- package/dist/helpers/EmailHelper.js +81 -0
- package/dist/helpers/EmailHelper.js.map +1 -0
- package/dist/helpers/EncryptionHelper.d.ts +6 -0
- package/dist/helpers/EncryptionHelper.d.ts.map +1 -0
- package/dist/helpers/EncryptionHelper.js +31 -0
- package/dist/helpers/EncryptionHelper.js.map +1 -0
- package/dist/helpers/EnvironmentBase.d.ts +17 -0
- package/dist/helpers/EnvironmentBase.d.ts.map +1 -0
- package/dist/helpers/EnvironmentBase.js +22 -0
- package/dist/helpers/EnvironmentBase.js.map +1 -0
- package/dist/helpers/FileStorageHelper.d.ts +15 -0
- package/dist/helpers/FileStorageHelper.d.ts.map +1 -0
- package/dist/helpers/FileStorageHelper.js +99 -0
- package/dist/helpers/FileStorageHelper.js.map +1 -0
- package/dist/helpers/Interfaces.d.ts +12 -0
- package/dist/helpers/Interfaces.d.ts.map +1 -0
- package/dist/helpers/Interfaces.js +3 -0
- package/dist/helpers/Interfaces.js.map +1 -0
- package/dist/helpers/LoggingHelper.d.ts +15 -0
- package/dist/helpers/LoggingHelper.d.ts.map +1 -0
- package/dist/helpers/LoggingHelper.js +83 -0
- package/dist/helpers/LoggingHelper.js.map +1 -0
- package/dist/helpers/MySqlHelper.d.ts +4 -0
- package/dist/helpers/MySqlHelper.d.ts.map +1 -0
- package/dist/helpers/MySqlHelper.js +10 -0
- package/dist/helpers/MySqlHelper.js.map +1 -0
- package/dist/helpers/OmitEmpty.d.ts +6 -0
- package/dist/helpers/OmitEmpty.d.ts.map +1 -0
- package/dist/helpers/OmitEmpty.js +94 -0
- package/dist/helpers/OmitEmpty.js.map +1 -0
- package/dist/helpers/Pool.d.ts +7 -0
- package/dist/helpers/Pool.d.ts.map +1 -0
- package/dist/helpers/Pool.js +55 -0
- package/dist/helpers/Pool.js.map +1 -0
- package/dist/helpers/index.d.ts +15 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +31 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/models/ErrorLog.d.ts +7 -0
- package/dist/models/ErrorLog.d.ts.map +1 -0
- package/dist/models/ErrorLog.js +7 -0
- package/dist/models/ErrorLog.js.map +1 -0
- package/dist/models/index.d.ts +2 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +6 -0
- package/dist/models/index.js.map +1 -0
- package/dist/tools/DBCreator.d.ts +1 -0
- package/dist/tools/DBCreator.d.ts.map +1 -0
- package/dist/tools/DBCreator.js +1 -0
- package/dist/tools/DBCreator.js.map +1 -0
- package/package.json +60 -0
- package/src/auth/AuthenticatedUser.ts +40 -0
- package/src/auth/CustomAuthProvider.ts +23 -0
- package/src/auth/Principal.ts +22 -0
- package/src/auth/index.ts +3 -0
- package/src/controllers/CustomBaseController.ts +74 -0
- package/src/controllers/ErrorController.ts +33 -0
- package/src/controllers/index.ts +2 -0
- package/src/helpers/AwsHelper.ts +108 -0
- package/src/helpers/BasePermissions.ts +15 -0
- package/src/helpers/DB.ts +41 -0
- package/src/helpers/DBCreator.ts +39 -0
- package/src/helpers/EmailHelper.ts +66 -0
- package/src/helpers/EncryptionHelper.ts +25 -0
- package/src/helpers/EnvironmentBase.ts +35 -0
- package/src/helpers/FileStorageHelper.ts +71 -0
- package/src/helpers/Interfaces.ts +2 -0
- package/src/helpers/LoggingHelper.ts +75 -0
- package/src/helpers/MySqlHelper.ts +5 -0
- package/src/helpers/OmitEmpty.ts +97 -0
- package/src/helpers/Pool.ts +55 -0
- package/src/helpers/index.ts +14 -0
- package/src/index.ts +3 -0
- package/src/models/ErrorLog.ts +7 -0
- package/src/models/index.ts +1 -0
- package/src/tools/DBCreator.ts +0 -0
- package/src/tools/templates/ChurchEmailTemplate.html +383 -0
- package/src/tools/templates/EmailTemplate.html +426 -0
- package/tsconfig.json +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Live Church Solutions
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# ApiHelper
|
|
2
|
+
|
|
3
|
+
Helper functions specific to ChurchApps API projects
|
|
4
|
+
|
|
5
|
+
## To Test
|
|
6
|
+
|
|
7
|
+
1. After making changes run `npm build` followed by `npm link` to expose the package locally
|
|
8
|
+
2. In your test project run `@npm link @churchapps/apihelper`
|
|
9
|
+
3. Rerun both after changes
|
|
10
|
+
|
|
11
|
+
## To Publish
|
|
12
|
+
|
|
13
|
+
1. Update version number in package.json
|
|
14
|
+
2. Run `npm run build`
|
|
15
|
+
3. Run `npm publish --access=public`
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Principal } from "./";
|
|
2
|
+
import { IPermission } from "../helpers/Interfaces";
|
|
3
|
+
export declare class AuthenticatedUser {
|
|
4
|
+
id: string;
|
|
5
|
+
churchId: string;
|
|
6
|
+
email: string;
|
|
7
|
+
apiName: string;
|
|
8
|
+
permissions: string[];
|
|
9
|
+
personId: string;
|
|
10
|
+
firstName: string;
|
|
11
|
+
lastName: string;
|
|
12
|
+
membershipStatus?: string;
|
|
13
|
+
groupIds?: string[];
|
|
14
|
+
constructor(principal: Principal);
|
|
15
|
+
checkAccess(permission: IPermission): boolean;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=AuthenticatedUser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthenticatedUser.d.ts","sourceRoot":"","sources":["../../src/auth/AuthenticatedUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAA;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,qBAAa,iBAAiB;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;gBAER,SAAS,EAAE,SAAS;IAahC,WAAW,CAAC,UAAU,EAAE,WAAW;CAW3C"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthenticatedUser = void 0;
|
|
4
|
+
class AuthenticatedUser {
|
|
5
|
+
constructor(principal) {
|
|
6
|
+
this.id = principal.details.id;
|
|
7
|
+
this.churchId = principal.details.churchId;
|
|
8
|
+
this.permissions = principal.details.permissions;
|
|
9
|
+
this.apiName = principal.details.apiName;
|
|
10
|
+
this.email = principal.details.email;
|
|
11
|
+
this.personId = principal.details.personId;
|
|
12
|
+
this.firstName = principal.details.firstName;
|
|
13
|
+
this.lastName = principal.details.lastName;
|
|
14
|
+
this.membershipStatus = principal.details.membershipStatus;
|
|
15
|
+
this.groupIds = principal.details.groupIds;
|
|
16
|
+
}
|
|
17
|
+
checkAccess(permission) {
|
|
18
|
+
var _a;
|
|
19
|
+
const key = (permission.apiName)
|
|
20
|
+
? permission.apiName + "_" + permission.contentType + "__" + permission.action
|
|
21
|
+
: permission.contentType + "__" + permission.action;
|
|
22
|
+
let result = false;
|
|
23
|
+
(_a = this.permissions) === null || _a === void 0 ? void 0 : _a.forEach((p) => {
|
|
24
|
+
if (p === key)
|
|
25
|
+
result = true;
|
|
26
|
+
});
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.AuthenticatedUser = AuthenticatedUser;
|
|
31
|
+
//# sourceMappingURL=AuthenticatedUser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthenticatedUser.js","sourceRoot":"","sources":["../../src/auth/AuthenticatedUser.ts"],"names":[],"mappings":";;;AAGA,MAAa,iBAAiB;IAY5B,YAAmB,SAAoB;QACrC,IAAI,CAA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
|
1
|
+
import { interfaces } from "inversify-express-utils";
|
|
2
|
+
import express from "express";
|
|
3
|
+
import { Principal } from "./";
|
|
4
|
+
export declare class CustomAuthProvider implements interfaces.AuthProvider {
|
|
5
|
+
getUser(req: express.Request, res: express.Response, next: express.NextFunction): Promise<Principal>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=CustomAuthProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomAuthProvider.d.ts","sourceRoot":"","sources":["../../src/auth/CustomAuthProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAG/B,qBACa,kBAAmB,YAAW,UAAU,CAAC,YAAY;IAEnD,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC;CAYlH"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.CustomAuthProvider = void 0;
|
|
22
|
+
const inversify_1 = require("inversify");
|
|
23
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
24
|
+
const _1 = require("./");
|
|
25
|
+
const __1 = require("..");
|
|
26
|
+
let CustomAuthProvider = class CustomAuthProvider {
|
|
27
|
+
// public async getUser(req: express.Request, res: express.Response, next: express.NextFunction): Promise<interfaces.Principal> {
|
|
28
|
+
getUser(req, res, next) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
const authHeader = req.headers.authorization;
|
|
31
|
+
if (authHeader) {
|
|
32
|
+
const token = authHeader.split(" ")[1];
|
|
33
|
+
if (!token)
|
|
34
|
+
return null;
|
|
35
|
+
const decoded = jsonwebtoken_1.default.verify(token, __1.EnvironmentBase.jwtSecret);
|
|
36
|
+
return decoded ? new _1.Principal(decoded) : null;
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
exports.CustomAuthProvider = CustomAuthProvider;
|
|
43
|
+
exports.CustomAuthProvider = CustomAuthProvider = __decorate([
|
|
44
|
+
(0, inversify_1.injectable)()
|
|
45
|
+
], CustomAuthProvider);
|
|
46
|
+
//# sourceMappingURL=CustomAuthProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomAuthProvider.js","sourceRoot":"","sources":["../../src/auth/CustomAuthProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,yCAAuC;AAGvC,gEAA+B;AAC/B,yBAA+B;AAC/B,0BAAqC;AAG9B,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B,iIAAiI;IACpH,OAAO,CAAC,GAAoB,EAAE,GAAqB,EAAE,IAA0B;;YAC1F,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC;YAC7C,IAAI,UAAU,EAAE;gBACd,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;gBACvC,IAAI,CAAC,KAAK;oBAAE,OAAO,IAAI,CAAC;gBACxB,MAAM,OAAO,GAAG,sBAAG,CAAC,MAAM,CAAC,KAAK,EAAE,mBAAe,CAAC,SAAS,CAAC,CAAC;gBAE7D,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,YAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;aAChD;YAED,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;CACF,CAAA;AAdY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,sBAAU,GAAE;GACA,kBAAkB,CAc9B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { interfaces } from "inversify-express-utils";
|
|
2
|
+
export declare class Principal implements interfaces.Principal {
|
|
3
|
+
details: any;
|
|
4
|
+
constructor(details: any);
|
|
5
|
+
isAuthenticated(): Promise<boolean>;
|
|
6
|
+
isResourceOwner(resourceId: any): Promise<boolean>;
|
|
7
|
+
isInRole(role: string): Promise<boolean>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=Principal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Principal.d.ts","sourceRoot":"","sources":["../../src/auth/Principal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,qBAAa,SAAU,YAAW,UAAU,CAAC,SAAS;IAC7C,OAAO,EAAE,GAAG,CAAC;gBAED,OAAO,EAAE,GAAG;IAIxB,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAInC,eAAe,CAAC,UAAU,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC;IAIlD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAIhD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Principal = void 0;
|
|
4
|
+
class Principal {
|
|
5
|
+
constructor(details) {
|
|
6
|
+
this.details = details;
|
|
7
|
+
}
|
|
8
|
+
isAuthenticated() {
|
|
9
|
+
return Promise.resolve(true);
|
|
10
|
+
}
|
|
11
|
+
isResourceOwner(resourceId) {
|
|
12
|
+
return Promise.resolve(resourceId === 1111);
|
|
13
|
+
}
|
|
14
|
+
isInRole(role) {
|
|
15
|
+
return Promise.resolve(role === "admin");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.Principal = Principal;
|
|
19
|
+
//# sourceMappingURL=Principal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Principal.js","sourceRoot":"","sources":["../../src/auth/Principal.ts"],"names":[],"mappings":";;;AAEA,MAAa,SAAS;IAGpB,YAAmB,OAAY;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEM,eAAe;QACpB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAEM,eAAe,CAAC,UAAe;QACpC,OAAO,OAAO,CAAC,OAAO,CAAC,UAAU,KAAK,IAAI,CAAC,CAAC;IAC9C,CAAC;IAEM,QAAQ,CAAC,IAAY;QAC1B,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC;IAC3C,CAAC;CAEF;AAnBD,8BAmBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Principal = exports.CustomAuthProvider = exports.AuthenticatedUser = void 0;
|
|
4
|
+
var AuthenticatedUser_1 = require("./AuthenticatedUser");
|
|
5
|
+
Object.defineProperty(exports, "AuthenticatedUser", { enumerable: true, get: function () { return AuthenticatedUser_1.AuthenticatedUser; } });
|
|
6
|
+
var CustomAuthProvider_1 = require("./CustomAuthProvider");
|
|
7
|
+
Object.defineProperty(exports, "CustomAuthProvider", { enumerable: true, get: function () { return CustomAuthProvider_1.CustomAuthProvider; } });
|
|
8
|
+
var Principal_1 = require("./Principal");
|
|
9
|
+
Object.defineProperty(exports, "Principal", { enumerable: true, get: function () { return Principal_1.Principal; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":";;;AAAA,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA;AAC1B,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA;AAC3B,yCAAwC;AAA/B,sGAAA,SAAS,OAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseHttpController } from "inversify-express-utils";
|
|
2
|
+
import express from "express";
|
|
3
|
+
import { LoggingHelper } from "../helpers/LoggingHelper";
|
|
4
|
+
import { AuthenticatedUser } from "../auth";
|
|
5
|
+
export declare class CustomBaseController extends BaseHttpController {
|
|
6
|
+
logger: LoggingHelper;
|
|
7
|
+
constructor();
|
|
8
|
+
error(errors: string[]): import("inversify-express-utils/lib/results").JsonResult;
|
|
9
|
+
denyAccess(errors: string[]): import("inversify-express-utils/lib/results").JsonResult;
|
|
10
|
+
authUser(): AuthenticatedUser;
|
|
11
|
+
include(req: express.Request, item: string): boolean;
|
|
12
|
+
actionWrapper(req: express.Request, res: express.Response, fetchFunction: (au: AuthenticatedUser) => any): Promise<any>;
|
|
13
|
+
actionWrapperAnon(req: express.Request, res: express.Response, fetchFunction: () => any): Promise<any>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=CustomBaseController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomBaseController.d.ts","sourceRoot":"","sources":["../../src/controllers/CustomBaseController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAa,MAAM,SAAS,CAAA;AAEtD,qBAAa,oBAAqB,SAAQ,kBAAkB;IAEjD,MAAM,EAAE,aAAa,CAAC;;IAOtB,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE;IAItB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE;IAI3B,QAAQ,IAAI,iBAAiB;IAK7B,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM;IAUpC,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,QAAQ,EAAE,aAAa,EAAE,CAAC,EAAE,EAAE,iBAAiB,KAAK,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAiBvH,iBAAiB,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;CAmBtH"}
|
|
@@ -0,0 +1,83 @@
|
|
|
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.CustomBaseController = void 0;
|
|
13
|
+
const inversify_express_utils_1 = require("inversify-express-utils");
|
|
14
|
+
const LoggingHelper_1 = require("../helpers/LoggingHelper");
|
|
15
|
+
const auth_1 = require("../auth");
|
|
16
|
+
class CustomBaseController extends inversify_express_utils_1.BaseHttpController {
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
this.logger = LoggingHelper_1.LoggingHelper.getCurrent();
|
|
20
|
+
}
|
|
21
|
+
error(errors) {
|
|
22
|
+
return this.json({ errors }, 500);
|
|
23
|
+
}
|
|
24
|
+
denyAccess(errors) {
|
|
25
|
+
return this.json({ errors }, 401);
|
|
26
|
+
}
|
|
27
|
+
authUser() {
|
|
28
|
+
if (this.httpContext.user === null)
|
|
29
|
+
return new auth_1.AuthenticatedUser(new auth_1.Principal({}));
|
|
30
|
+
else
|
|
31
|
+
return new auth_1.AuthenticatedUser(this.httpContext.user);
|
|
32
|
+
}
|
|
33
|
+
include(req, item) {
|
|
34
|
+
let result = false;
|
|
35
|
+
if (req.query.include !== undefined) {
|
|
36
|
+
const value = req.query.include;
|
|
37
|
+
const items = value.split(",");
|
|
38
|
+
if (items.indexOf(item) > -1)
|
|
39
|
+
result = true;
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
actionWrapper(req, res, fetchFunction) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
try {
|
|
46
|
+
const result = yield fetchFunction(this.authUser());
|
|
47
|
+
yield this.logger.flush();
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
try {
|
|
52
|
+
this.logger.error(e);
|
|
53
|
+
yield this.logger.flush();
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
console.log(e);
|
|
57
|
+
}
|
|
58
|
+
return this.internalServerError(e);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
actionWrapperAnon(req, res, fetchFunction) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
try {
|
|
65
|
+
const result = yield fetchFunction();
|
|
66
|
+
yield this.logger.flush();
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
try {
|
|
71
|
+
this.logger.error(e);
|
|
72
|
+
yield this.logger.flush();
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
console.log(e);
|
|
76
|
+
}
|
|
77
|
+
return this.internalServerError(e);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.CustomBaseController = CustomBaseController;
|
|
83
|
+
//# sourceMappingURL=CustomBaseController.js.map
|
|
@@ -0,0 +1 @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AAM,MAAM,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;gBACpD,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;gBAC1B,OAAO,MAAM,CAAC;aACjB;YAAC,OAAO,CAAK,EAAE;gBACZ,IAAI;oBACA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;oBACrB,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;iBAC7B;gBAAC,OAAO,CAAC,EAAE;oBACR,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;iBAClB;gBAED,OAAO,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;aACtC;QACL,CAAC;KAAA;IAEY,iBAAiB,CAAC,GAAoB,EAAE,GAAqB,EAAE,aAAwB;;YAChG,IAAI;gBACA,MAAM,MAAM,GAAG,MAAM,aAAa,EAAE,CAAC;gBACrC,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;gBAC1B,OAAO,MAAM,CAAC;aACjB;YAAC,OAAO,CAAK,EAAE;gBACZ,IAAI;oBACA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;oBACrB,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;iBAC7B;gBAAC,OAAO,CAAC,EAAE;oBACR,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;iBAClB;gBAED,OAAO,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;aACtC;QACL,CAAC;KAAA;CAIJ;AApED,oDAoEC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import express from "express";
|
|
2
|
+
import { CustomBaseController } from "./CustomBaseController";
|
|
3
|
+
import { ErrorLog } from "../models";
|
|
4
|
+
export declare class ErrorController extends CustomBaseController {
|
|
5
|
+
save(req: express.Request<{}, {}, ErrorLog[]>, res: express.Response): Promise<any>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=ErrorController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorController.d.ts","sourceRoot":"","sources":["../../src/controllers/ErrorController.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAGpC,qBACa,eAAgB,SAAQ,oBAAoB;IAGxC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;CAsBnG"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.ErrorController = void 0;
|
|
25
|
+
const inversify_express_utils_1 = require("inversify-express-utils");
|
|
26
|
+
const express_1 = __importDefault(require("express"));
|
|
27
|
+
const CustomBaseController_1 = require("./CustomBaseController");
|
|
28
|
+
let ErrorController = class ErrorController extends CustomBaseController_1.CustomBaseController {
|
|
29
|
+
save(req, res) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
// try {
|
|
32
|
+
/*
|
|
33
|
+
try {
|
|
34
|
+
au = this.authUser();
|
|
35
|
+
} catch (e) {
|
|
36
|
+
this.logger.log(req.body[0].application, "info", e);
|
|
37
|
+
}*/
|
|
38
|
+
req.body.forEach(error => {
|
|
39
|
+
let fullMessage = error.message;
|
|
40
|
+
if (error.additionalDetails !== undefined)
|
|
41
|
+
fullMessage += "\n" + error.additionalDetails;
|
|
42
|
+
// if (au !== null) fullMessage += "\nUser: " + au.id + " Church: " + au.churchId;
|
|
43
|
+
this.logger.log(error.application, error.level, fullMessage);
|
|
44
|
+
});
|
|
45
|
+
yield this.logger.flush();
|
|
46
|
+
return req.body;
|
|
47
|
+
// } catch (e) {
|
|
48
|
+
// console.log(e)
|
|
49
|
+
// };
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
exports.ErrorController = ErrorController;
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, inversify_express_utils_1.httpPost)("/"),
|
|
56
|
+
__metadata("design:type", Function),
|
|
57
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
58
|
+
__metadata("design:returntype", Promise)
|
|
59
|
+
], ErrorController.prototype, "save", null);
|
|
60
|
+
exports.ErrorController = ErrorController = __decorate([
|
|
61
|
+
(0, inversify_express_utils_1.controller)("/errors")
|
|
62
|
+
], ErrorController);
|
|
63
|
+
//# sourceMappingURL=ErrorController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorController.js","sourceRoot":"","sources":["../../src/controllers/ErrorController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,qEAA8G;AAC9G,sDAA8B;AAC9B,iEAA6D;AAKtD,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,2CAAoB;IAGxC,IAAI,CAAC,GAAwC,EAAE,GAAqB;;YAC7E,QAAQ;YACR;;;;;eAKG;YACH,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBACrB,IAAI,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC;gBAChC,IAAI,KAAK,CAAC,iBAAiB,KAAK,SAAS;oBAAE,WAAW,IAAI,IAAI,GAAG,KAAK,CAAC,iBAAiB,CAAC;gBACzF,kFAAkF;gBAClF,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;YACjE,CAAC,CAAC,CAAC;YACH,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAC1B,OAAO,GAAG,CAAC,IAAI,CAAC;YAChB,gBAAgB;YAChB,iBAAiB;YACjB,KAAK;QAET,CAAC;KAAA;CAEJ,CAAA;AAzBY,0CAAe;AAGX;IADZ,IAAA,kCAAQ,EAAC,GAAG,CAAC;;;;2CAqBb;0BAvBQ,eAAe;IAD3B,IAAA,oCAAU,EAAC,SAAS,CAAC;GACT,eAAe,CAyB3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/controllers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErrorController = exports.CustomBaseController = void 0;
|
|
4
|
+
var CustomBaseController_1 = require("./CustomBaseController");
|
|
5
|
+
Object.defineProperty(exports, "CustomBaseController", { enumerable: true, get: function () { return CustomBaseController_1.CustomBaseController; } });
|
|
6
|
+
var ErrorController_1 = require("./ErrorController");
|
|
7
|
+
Object.defineProperty(exports, "ErrorController", { enumerable: true, get: function () { return ErrorController_1.ErrorController; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/controllers/index.ts"],"names":[],"mappings":";;;AAAA,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAC7B,qDAAoD;AAA3C,kHAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ByteBuffer } from "aws-sdk/clients/cloudtrail";
|
|
2
|
+
export declare class AwsHelper {
|
|
3
|
+
private static S3;
|
|
4
|
+
static S3PresignedUrl(key: string): Promise<any>;
|
|
5
|
+
static S3Upload(key: string, contentType: string, contents: ByteBuffer): Promise<void>;
|
|
6
|
+
static S3Move(oldKey: string, newKey: string): Promise<void>;
|
|
7
|
+
static S3Remove(key: string): Promise<void>;
|
|
8
|
+
static S3Rename(oldKey: string, newKey: string): Promise<void>;
|
|
9
|
+
static S3Copy(oldKey: string, newKey: string): Promise<void>;
|
|
10
|
+
static S3List(path: string): Promise<string[]>;
|
|
11
|
+
static S3Read(key: string): Promise<any>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=AwsHelper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AwsHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/AwsHelper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAGxD,qBAAa,SAAS;IAEpB,OAAO,CAAC,MAAM,CAAC,EAAE;IAIjB,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAuBhD,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAWtF,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAc5D,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WAW9B,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKpE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WAW/C,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;WAavC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;CAS/C"}
|
|
@@ -0,0 +1,131 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AwsHelper = void 0;
|
|
16
|
+
const aws_sdk_1 = __importDefault(require("aws-sdk"));
|
|
17
|
+
const EnvironmentBase_1 = require("./EnvironmentBase");
|
|
18
|
+
class AwsHelper {
|
|
19
|
+
static S3() {
|
|
20
|
+
return new aws_sdk_1.default.S3({ apiVersion: "2006-03-01" });
|
|
21
|
+
}
|
|
22
|
+
static S3PresignedUrl(key) {
|
|
23
|
+
if (key.indexOf("/") === 0)
|
|
24
|
+
key = key.substring(1, key.length);
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
const params = { Bucket: EnvironmentBase_1.EnvironmentBase.s3Bucket };
|
|
27
|
+
params.Conditions = [
|
|
28
|
+
{ acl: "public-read" },
|
|
29
|
+
{ bucket: EnvironmentBase_1.EnvironmentBase.s3Bucket },
|
|
30
|
+
{ key },
|
|
31
|
+
["starts-with", "$Content-Type", ""],
|
|
32
|
+
];
|
|
33
|
+
params.Expires = 1200;
|
|
34
|
+
this.S3().createPresignedPost(params, (error, data) => {
|
|
35
|
+
if (error)
|
|
36
|
+
reject(error);
|
|
37
|
+
else {
|
|
38
|
+
data.key = key;
|
|
39
|
+
resolve(data);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
static S3Upload(key, contentType, contents) {
|
|
45
|
+
if (key.indexOf("/") === 0)
|
|
46
|
+
key = key.substring(1, key.length);
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
const params = { Bucket: EnvironmentBase_1.EnvironmentBase.s3Bucket, Key: key, Body: contents, ACL: "public-read", ContentType: contentType };
|
|
49
|
+
this.S3().upload(params, (error, data) => {
|
|
50
|
+
if (error)
|
|
51
|
+
reject(error);
|
|
52
|
+
else
|
|
53
|
+
resolve();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
static S3Move(oldKey, newKey) {
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
const params = { Bucket: EnvironmentBase_1.EnvironmentBase.s3Bucket, Key: newKey, CopySource: EnvironmentBase_1.EnvironmentBase.s3Bucket + "/" + oldKey };
|
|
60
|
+
this.S3().copyObject(params, (error, data) => {
|
|
61
|
+
if (error)
|
|
62
|
+
reject(error);
|
|
63
|
+
else {
|
|
64
|
+
this.S3Remove(oldKey).then(() => {
|
|
65
|
+
resolve();
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
static S3Remove(key) {
|
|
72
|
+
if (key.indexOf("/") === 0)
|
|
73
|
+
key = key.substring(1, key.length - 1);
|
|
74
|
+
return new Promise((resolve, reject) => {
|
|
75
|
+
const params = { Bucket: EnvironmentBase_1.EnvironmentBase.s3Bucket, Key: key };
|
|
76
|
+
this.S3().deleteObject(params, (error, data) => {
|
|
77
|
+
if (error)
|
|
78
|
+
reject(error);
|
|
79
|
+
else
|
|
80
|
+
resolve();
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
static S3Rename(oldKey, newKey) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
yield this.S3Copy(oldKey, newKey);
|
|
87
|
+
yield this.S3Remove(oldKey);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
static S3Copy(oldKey, newKey) {
|
|
91
|
+
return new Promise((resolve, reject) => {
|
|
92
|
+
const source = "/" + EnvironmentBase_1.EnvironmentBase.s3Bucket + "/" + oldKey;
|
|
93
|
+
const params = { Bucket: EnvironmentBase_1.EnvironmentBase.s3Bucket, Key: newKey, CopySource: source, ACL: "public-read" };
|
|
94
|
+
this.S3().copyObject(params, (error, data) => {
|
|
95
|
+
if (error)
|
|
96
|
+
reject(error);
|
|
97
|
+
else
|
|
98
|
+
resolve();
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
static S3List(path) {
|
|
103
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
return new Promise((resolve, reject) => {
|
|
105
|
+
this.S3().listObjectsV2({ Bucket: EnvironmentBase_1.EnvironmentBase.s3Bucket, Prefix: path, MaxKeys: 100000 }, (error, data) => {
|
|
106
|
+
if (error)
|
|
107
|
+
reject(error);
|
|
108
|
+
else {
|
|
109
|
+
const result = [];
|
|
110
|
+
data.Contents.forEach(v => { result.push(v.Key); });
|
|
111
|
+
resolve(result);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
static S3Read(key) {
|
|
118
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
return new Promise((resolve, reject) => {
|
|
120
|
+
this.S3().getObject({ Bucket: EnvironmentBase_1.EnvironmentBase.s3Bucket, Key: key }, (error, data) => {
|
|
121
|
+
if (error)
|
|
122
|
+
resolve(null);
|
|
123
|
+
else
|
|
124
|
+
resolve(data.Body.toString());
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
exports.AwsHelper = AwsHelper;
|
|
131
|
+
//# sourceMappingURL=AwsHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AwsHelper.js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uGC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare class BasePermissions {
|
|
2
|
+
static forms: {
|
|
3
|
+
admin: {
|
|
4
|
+
contentType: string;
|
|
5
|
+
action: string;
|
|
6
|
+
};
|
|
7
|
+
edit: {
|
|
8
|
+
contentType: string;
|
|
9
|
+
action: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
static links: {
|
|
13
|
+
edit: {
|
|
14
|
+
contentType: string;
|
|
15
|
+
action: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
static pages: {
|
|
19
|
+
edit: {
|
|
20
|
+
contentType: string;
|
|
21
|
+
action: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
static settings: {
|
|
25
|
+
edit: {
|
|
26
|
+
contentType: string;
|
|
27
|
+
action: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=BasePermissions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasePermissions.d.ts","sourceRoot":"","sources":["../../src/helpers/BasePermissions.ts"],"names":[],"mappings":"AAAA,qBAAa,eAAe;IAC1B,MAAM,CAAC,KAAK;;;;;;;;;MAGV;IACF,MAAM,CAAC,KAAK;;;;;MAEV;IACF,MAAM,CAAC,KAAK;;;;;MAEV;IACF,MAAM,CAAC,QAAQ;;;;;MAEb;CACH"}
|