dce-expresskit 4.0.0-beta.10
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/.eslintrc.js +93 -0
- package/LICENSE +21 -0
- package/README.md +17 -0
- package/genEncodedSecret.ts +107 -0
- package/genSalt.ts +15 -0
- package/lib/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.d.ts +6 -0
- package/lib/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.js +13 -0
- package/lib/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.js.map +1 -0
- package/lib/constants/LOG_REVIEW_STATUS_ROUTE.d.ts +7 -0
- package/lib/constants/LOG_REVIEW_STATUS_ROUTE.js +14 -0
- package/lib/constants/LOG_REVIEW_STATUS_ROUTE.js.map +1 -0
- package/lib/constants/LOG_ROUTE_PATH.d.ts +6 -0
- package/lib/constants/LOG_ROUTE_PATH.js +13 -0
- package/lib/constants/LOG_ROUTE_PATH.js.map +1 -0
- package/lib/constants/ROUTE_PATH_PREFIX.d.ts +6 -0
- package/lib/constants/ROUTE_PATH_PREFIX.js +9 -0
- package/lib/constants/ROUTE_PATH_PREFIX.js.map +1 -0
- package/lib/errors/ErrorWithCode.d.ts +9 -0
- package/lib/errors/ErrorWithCode.js +33 -0
- package/lib/errors/ErrorWithCode.js.map +1 -0
- package/lib/helpers/addDBEditorEndpoints/generateEndpointPath.d.ts +9 -0
- package/lib/helpers/addDBEditorEndpoints/generateEndpointPath.js +17 -0
- package/lib/helpers/addDBEditorEndpoints/generateEndpointPath.js.map +1 -0
- package/lib/helpers/addDBEditorEndpoints/index.d.ts +41 -0
- package/lib/helpers/addDBEditorEndpoints/index.js +134 -0
- package/lib/helpers/addDBEditorEndpoints/index.js.map +1 -0
- package/lib/helpers/dataSigner.d.ts +40 -0
- package/lib/helpers/dataSigner.js +236 -0
- package/lib/helpers/dataSigner.js.map +1 -0
- package/lib/helpers/genRouteHandler.d.ts +75 -0
- package/lib/helpers/genRouteHandler.js +661 -0
- package/lib/helpers/genRouteHandler.js.map +1 -0
- package/lib/helpers/handleError.d.ts +18 -0
- package/lib/helpers/handleError.js +51 -0
- package/lib/helpers/handleError.js.map +1 -0
- package/lib/helpers/handleSuccess.d.ts +8 -0
- package/lib/helpers/handleSuccess.js +20 -0
- package/lib/helpers/handleSuccess.js.map +1 -0
- package/lib/helpers/initCrossServerCredentialCollection.d.ts +11 -0
- package/lib/helpers/initCrossServerCredentialCollection.js +15 -0
- package/lib/helpers/initCrossServerCredentialCollection.js.map +1 -0
- package/lib/helpers/initLogCollection.d.ts +11 -0
- package/lib/helpers/initLogCollection.js +26 -0
- package/lib/helpers/initLogCollection.js.map +1 -0
- package/lib/helpers/initServer.d.ts +45 -0
- package/lib/helpers/initServer.js +293 -0
- package/lib/helpers/initServer.js.map +1 -0
- package/lib/helpers/parseUserAgent.d.ts +17 -0
- package/lib/helpers/parseUserAgent.js +108 -0
- package/lib/helpers/parseUserAgent.js.map +1 -0
- package/lib/helpers/visitEndpointOnAnotherServer/index.d.ts +18 -0
- package/lib/helpers/visitEndpointOnAnotherServer/index.js +156 -0
- package/lib/helpers/visitEndpointOnAnotherServer/index.js.map +1 -0
- package/lib/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.d.ts +23 -0
- package/lib/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.js +168 -0
- package/lib/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.js.map +1 -0
- package/lib/html/genErrorPage.d.ts +19 -0
- package/lib/html/genErrorPage.js +27 -0
- package/lib/html/genErrorPage.js.map +1 -0
- package/lib/html/genInfoPage.d.ts +13 -0
- package/lib/html/genInfoPage.js +16 -0
- package/lib/html/genInfoPage.js.map +1 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +68 -0
- package/lib/index.js.map +1 -0
- package/lib/types/CrossServerCredential.d.ts +11 -0
- package/lib/types/CrossServerCredential.js +3 -0
- package/lib/types/CrossServerCredential.js.map +1 -0
- package/lib/types/ExpressKitErrorCode.d.ts +31 -0
- package/lib/types/ExpressKitErrorCode.js +38 -0
- package/lib/types/ExpressKitErrorCode.js.map +1 -0
- package/package.json +53 -0
- package/src/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.ts +9 -0
- package/src/constants/LOG_REVIEW_STATUS_ROUTE.ts +10 -0
- package/src/constants/LOG_ROUTE_PATH.ts +9 -0
- package/src/constants/ROUTE_PATH_PREFIX.ts +7 -0
- package/src/errors/ErrorWithCode.tsx +15 -0
- package/src/helpers/addDBEditorEndpoints/generateEndpointPath.ts +16 -0
- package/src/helpers/addDBEditorEndpoints/index.ts +130 -0
- package/src/helpers/dataSigner.ts +306 -0
- package/src/helpers/genRouteHandler.ts +914 -0
- package/src/helpers/handleError.ts +66 -0
- package/src/helpers/handleSuccess.ts +18 -0
- package/src/helpers/initCrossServerCredentialCollection.ts +19 -0
- package/src/helpers/initLogCollection.ts +31 -0
- package/src/helpers/initServer.ts +284 -0
- package/src/helpers/parseUserAgent.ts +108 -0
- package/src/helpers/visitEndpointOnAnotherServer/index.ts +157 -0
- package/src/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.ts +164 -0
- package/src/html/genErrorPage.ts +144 -0
- package/src/html/genInfoPage.ts +101 -0
- package/src/index.ts +125 -0
- package/src/types/CrossServerCredential.ts +16 -0
- package/src/types/ExpressKitErrorCode.ts +37 -0
- package/tsconfig.json +19 -0
package/lib/index.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ParamType = exports.LogBuiltInMetadata = exports.LogAction = exports.LogSource = exports.LogType = exports.DayOfWeek = exports.visitEndpointOnAnotherServer = exports.addDBEditorEndpoints = exports.initCrossServerCredentialCollection = exports.initLogCollection = exports.handleSuccess = exports.handleError = exports.genRouteHandler = exports.initServer = exports.shuffleArray = exports.capitalize = exports.someAsync = exports.mapAsync = exports.forEachAsync = exports.filterAsync = exports.everyAsync = exports.prefixWithAOrAn = exports.getLocalTimeInfo = exports.genCommaList = exports.compareArraysByProp = exports.extractProp = exports.genCSV = exports.getMonthName = exports.parallelLimit = exports.onlyKeepLetters = exports.stringsToHumanReadableList = exports.getPartOfDay = exports.getHumanReadableDate = exports.startMinWait = exports.getTimeInfoInET = exports.getOrdinal = exports.waitMs = exports.sum = exports.roundToNumDecimals = exports.padZerosLeft = exports.padDecimalZeros = exports.forceNumIntoBounds = exports.floorToNumDecimals = exports.ceilToNumDecimals = exports.avg = exports.abbreviate = exports.DAY_IN_MS = exports.HOUR_IN_MS = exports.MINUTE_IN_MS = exports.ErrorWithCode = void 0;
|
|
7
|
+
// Import dce-reactkit
|
|
8
|
+
var dce_reactkit_1 = require("dce-reactkit");
|
|
9
|
+
Object.defineProperty(exports, "abbreviate", { enumerable: true, get: function () { return dce_reactkit_1.abbreviate; } });
|
|
10
|
+
Object.defineProperty(exports, "avg", { enumerable: true, get: function () { return dce_reactkit_1.avg; } });
|
|
11
|
+
Object.defineProperty(exports, "ceilToNumDecimals", { enumerable: true, get: function () { return dce_reactkit_1.ceilToNumDecimals; } });
|
|
12
|
+
Object.defineProperty(exports, "floorToNumDecimals", { enumerable: true, get: function () { return dce_reactkit_1.floorToNumDecimals; } });
|
|
13
|
+
Object.defineProperty(exports, "forceNumIntoBounds", { enumerable: true, get: function () { return dce_reactkit_1.forceNumIntoBounds; } });
|
|
14
|
+
Object.defineProperty(exports, "padDecimalZeros", { enumerable: true, get: function () { return dce_reactkit_1.padDecimalZeros; } });
|
|
15
|
+
Object.defineProperty(exports, "padZerosLeft", { enumerable: true, get: function () { return dce_reactkit_1.padZerosLeft; } });
|
|
16
|
+
Object.defineProperty(exports, "roundToNumDecimals", { enumerable: true, get: function () { return dce_reactkit_1.roundToNumDecimals; } });
|
|
17
|
+
Object.defineProperty(exports, "sum", { enumerable: true, get: function () { return dce_reactkit_1.sum; } });
|
|
18
|
+
Object.defineProperty(exports, "waitMs", { enumerable: true, get: function () { return dce_reactkit_1.waitMs; } });
|
|
19
|
+
Object.defineProperty(exports, "getOrdinal", { enumerable: true, get: function () { return dce_reactkit_1.getOrdinal; } });
|
|
20
|
+
Object.defineProperty(exports, "getTimeInfoInET", { enumerable: true, get: function () { return dce_reactkit_1.getTimeInfoInET; } });
|
|
21
|
+
Object.defineProperty(exports, "startMinWait", { enumerable: true, get: function () { return dce_reactkit_1.startMinWait; } });
|
|
22
|
+
Object.defineProperty(exports, "getHumanReadableDate", { enumerable: true, get: function () { return dce_reactkit_1.getHumanReadableDate; } });
|
|
23
|
+
Object.defineProperty(exports, "getPartOfDay", { enumerable: true, get: function () { return dce_reactkit_1.getPartOfDay; } });
|
|
24
|
+
Object.defineProperty(exports, "stringsToHumanReadableList", { enumerable: true, get: function () { return dce_reactkit_1.stringsToHumanReadableList; } });
|
|
25
|
+
Object.defineProperty(exports, "onlyKeepLetters", { enumerable: true, get: function () { return dce_reactkit_1.onlyKeepLetters; } });
|
|
26
|
+
Object.defineProperty(exports, "parallelLimit", { enumerable: true, get: function () { return dce_reactkit_1.parallelLimit; } });
|
|
27
|
+
Object.defineProperty(exports, "getMonthName", { enumerable: true, get: function () { return dce_reactkit_1.getMonthName; } });
|
|
28
|
+
Object.defineProperty(exports, "genCSV", { enumerable: true, get: function () { return dce_reactkit_1.genCSV; } });
|
|
29
|
+
Object.defineProperty(exports, "extractProp", { enumerable: true, get: function () { return dce_reactkit_1.extractProp; } });
|
|
30
|
+
Object.defineProperty(exports, "compareArraysByProp", { enumerable: true, get: function () { return dce_reactkit_1.compareArraysByProp; } });
|
|
31
|
+
Object.defineProperty(exports, "getLocalTimeInfo", { enumerable: true, get: function () { return dce_reactkit_1.getLocalTimeInfo; } });
|
|
32
|
+
Object.defineProperty(exports, "genCommaList", { enumerable: true, get: function () { return dce_reactkit_1.genCommaList; } });
|
|
33
|
+
Object.defineProperty(exports, "prefixWithAOrAn", { enumerable: true, get: function () { return dce_reactkit_1.prefixWithAOrAn; } });
|
|
34
|
+
Object.defineProperty(exports, "everyAsync", { enumerable: true, get: function () { return dce_reactkit_1.everyAsync; } });
|
|
35
|
+
Object.defineProperty(exports, "filterAsync", { enumerable: true, get: function () { return dce_reactkit_1.filterAsync; } });
|
|
36
|
+
Object.defineProperty(exports, "forEachAsync", { enumerable: true, get: function () { return dce_reactkit_1.forEachAsync; } });
|
|
37
|
+
Object.defineProperty(exports, "mapAsync", { enumerable: true, get: function () { return dce_reactkit_1.mapAsync; } });
|
|
38
|
+
Object.defineProperty(exports, "someAsync", { enumerable: true, get: function () { return dce_reactkit_1.someAsync; } });
|
|
39
|
+
Object.defineProperty(exports, "capitalize", { enumerable: true, get: function () { return dce_reactkit_1.capitalize; } });
|
|
40
|
+
Object.defineProperty(exports, "shuffleArray", { enumerable: true, get: function () { return dce_reactkit_1.shuffleArray; } });
|
|
41
|
+
Object.defineProperty(exports, "DayOfWeek", { enumerable: true, get: function () { return dce_reactkit_1.DayOfWeek; } });
|
|
42
|
+
Object.defineProperty(exports, "LogType", { enumerable: true, get: function () { return dce_reactkit_1.LogType; } });
|
|
43
|
+
Object.defineProperty(exports, "LogSource", { enumerable: true, get: function () { return dce_reactkit_1.LogSource; } });
|
|
44
|
+
Object.defineProperty(exports, "LogAction", { enumerable: true, get: function () { return dce_reactkit_1.LogAction; } });
|
|
45
|
+
Object.defineProperty(exports, "LogBuiltInMetadata", { enumerable: true, get: function () { return dce_reactkit_1.LogBuiltInMetadata; } });
|
|
46
|
+
Object.defineProperty(exports, "MINUTE_IN_MS", { enumerable: true, get: function () { return dce_reactkit_1.MINUTE_IN_MS; } });
|
|
47
|
+
Object.defineProperty(exports, "HOUR_IN_MS", { enumerable: true, get: function () { return dce_reactkit_1.HOUR_IN_MS; } });
|
|
48
|
+
Object.defineProperty(exports, "DAY_IN_MS", { enumerable: true, get: function () { return dce_reactkit_1.DAY_IN_MS; } });
|
|
49
|
+
Object.defineProperty(exports, "ErrorWithCode", { enumerable: true, get: function () { return dce_reactkit_1.ErrorWithCode; } });
|
|
50
|
+
Object.defineProperty(exports, "ParamType", { enumerable: true, get: function () { return dce_reactkit_1.ParamType; } });
|
|
51
|
+
// Import helpers
|
|
52
|
+
var initCrossServerCredentialCollection_1 = __importDefault(require("./helpers/initCrossServerCredentialCollection"));
|
|
53
|
+
exports.initCrossServerCredentialCollection = initCrossServerCredentialCollection_1.default;
|
|
54
|
+
var initLogCollection_1 = __importDefault(require("./helpers/initLogCollection"));
|
|
55
|
+
exports.initLogCollection = initLogCollection_1.default;
|
|
56
|
+
var initServer_1 = __importDefault(require("./helpers/initServer"));
|
|
57
|
+
exports.initServer = initServer_1.default;
|
|
58
|
+
var genRouteHandler_1 = __importDefault(require("./helpers/genRouteHandler"));
|
|
59
|
+
exports.genRouteHandler = genRouteHandler_1.default;
|
|
60
|
+
var handleError_1 = __importDefault(require("./helpers/handleError"));
|
|
61
|
+
exports.handleError = handleError_1.default;
|
|
62
|
+
var handleSuccess_1 = __importDefault(require("./helpers/handleSuccess"));
|
|
63
|
+
exports.handleSuccess = handleSuccess_1.default;
|
|
64
|
+
var addDBEditorEndpoints_1 = __importDefault(require("./helpers/addDBEditorEndpoints"));
|
|
65
|
+
exports.addDBEditorEndpoints = addDBEditorEndpoints_1.default;
|
|
66
|
+
var visitEndpointOnAnotherServer_1 = __importDefault(require("./helpers/visitEndpointOnAnotherServer"));
|
|
67
|
+
exports.visitEndpointOnAnotherServer = visitEndpointOnAnotherServer_1.default;
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,sBAAsB;AACtB,6CA8CsB;AAwBpB,2FArEA,yBAAU,OAqEA;AACV,oFArEA,kBAAG,OAqEA;AACH,kGArEA,gCAAiB,OAqEA;AACjB,mGArEA,iCAAkB,OAqEA;AAClB,mGArEA,iCAAkB,OAqEA;AAClB,gGArEA,8BAAe,OAqEA;AACf,6FArEA,2BAAY,OAqEA;AACZ,mGArEA,iCAAkB,OAqEA;AAClB,oFArEA,kBAAG,OAqEA;AACH,uFArEA,qBAAM,OAqEA;AACN,2FArEA,yBAAU,OAqEA;AACV,gGArEA,8BAAe,OAqEA;AACf,6FArEA,2BAAY,OAqEA;AACZ,qGArEA,mCAAoB,OAqEA;AACpB,6FArEA,2BAAY,OAqEA;AACZ,2GArEA,yCAA0B,OAqEA;AAC1B,gGArEA,8BAAe,OAqEA;AACf,8FArEA,4BAAa,OAqEA;AACb,6FArEA,2BAAY,OAqEA;AACZ,uFArEA,qBAAM,OAqEA;AACN,4FArEA,0BAAW,OAqEA;AACX,oGArEA,kCAAmB,OAqEA;AAEnB,iGAtEA,+BAAgB,OAsEA;AADhB,6FApEA,2BAAY,OAoEA;AAEZ,gGArEA,8BAAe,OAqEA;AACf,2FArEA,yBAAU,OAqEA;AACV,4FArEA,0BAAW,OAqEA;AACX,6FArEA,2BAAY,OAqEA;AACZ,yFArEA,uBAAQ,OAqEA;AACR,0FArEA,wBAAS,OAqEA;AACT,2FArEA,yBAAU,OAqEA;AACV,6FArEA,2BAAY,OAqEA;AAWZ,0FA/EA,wBAAS,OA+EA;AAET,wFA/EA,sBAAO,OA+EA;AACP,0FA/EA,wBAAS,OA+EA;AACT,0FA/EA,wBAAS,OA+EA;AACT,mGA/EA,iCAAkB,OA+EA;AAnDlB,6FAzBA,2BAAY,OAyBA;AACZ,2FAzBA,yBAAU,OAyBA;AACV,0FAzBA,wBAAS,OAyBA;AAJT,8FApBA,4BAAa,OAoBA;AA0Db,0FA7EA,wBAAS,OA6EA;AA1EX,iBAAiB;AACjB,sHAAgG;AA2D9F,8CA3DK,6CAAmC,CA2DL;AA1DrC,kFAA4D;AAyD1D,4BAzDK,2BAAiB,CAyDL;AAxDnB,oEAA8C;AAoD5C,qBApDK,oBAAU,CAoDL;AAnDZ,8EAAwD;AAoDtD,0BApDK,yBAAe,CAoDL;AAnDjB,sEAAgD;AAoD9C,sBApDK,qBAAW,CAoDL;AAnDb,0EAAoD;AAoDlD,wBApDK,uBAAa,CAoDL;AAnDf,wFAAkE;AAsDhE,+BAtDK,8BAAoB,CAsDL;AArDtB,wGAAkF;AAsDhF,uCAtDK,sCAA4B,CAsDL"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CrossServerCredential.js","sourceRoot":"","sources":["../../src/types/CrossServerCredential.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List of error codes built into the express kit
|
|
3
|
+
* @author Gabe Abrams
|
|
4
|
+
*/
|
|
5
|
+
declare enum ExpressKitErrorCode {
|
|
6
|
+
WrongCourse = "DEK6",
|
|
7
|
+
NotTTM = "DEK9",
|
|
8
|
+
NotAdmin = "DEK10",
|
|
9
|
+
NotAllowedToReviewLogs = "DEK11",
|
|
10
|
+
ThemeCheckedBeforeReactKitReady = "DEK12",
|
|
11
|
+
InvalidParameter = "DEK5",
|
|
12
|
+
MissingParameter = "DEK4",
|
|
13
|
+
NotConnected = "DEK14",
|
|
14
|
+
SelfSigned = "DEK15",
|
|
15
|
+
ResponseParseError = "DEK16",
|
|
16
|
+
SignedRequestUnparseable = "DEK28",
|
|
17
|
+
SignedRequestInvalidCollection = "DEK21",
|
|
18
|
+
SignedRequestInvalidCredential = "DEK23",
|
|
19
|
+
SignedRequestInvalidScope = "DEK22",
|
|
20
|
+
SignedRequestInvalidTimestamp = "DEK24",
|
|
21
|
+
SignedRequestInvalidSignature = "DEK25",
|
|
22
|
+
SignedRequestInvalidBody = "DEK26",
|
|
23
|
+
CrossServerNoCredentialsToSignWith = "DEK27",
|
|
24
|
+
CrossServerMissingSignedRequestInfo = "DEK29",
|
|
25
|
+
CrossServerNoCredentialEncodingSalt = "DEK30",
|
|
26
|
+
NoOauthLib = "DEK31",
|
|
27
|
+
NoCryptoLib = "DEK32",
|
|
28
|
+
InvalidCrossServerCredentialsFormat = "DEK33",
|
|
29
|
+
UnknownCrossServerError = "DEK34"
|
|
30
|
+
}
|
|
31
|
+
export default ExpressKitErrorCode;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Highest error code = DEK34
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
/**
|
|
5
|
+
* List of error codes built into the express kit
|
|
6
|
+
* @author Gabe Abrams
|
|
7
|
+
*/
|
|
8
|
+
var ExpressKitErrorCode;
|
|
9
|
+
(function (ExpressKitErrorCode) {
|
|
10
|
+
// General errors
|
|
11
|
+
ExpressKitErrorCode["WrongCourse"] = "DEK6";
|
|
12
|
+
ExpressKitErrorCode["NotTTM"] = "DEK9";
|
|
13
|
+
ExpressKitErrorCode["NotAdmin"] = "DEK10";
|
|
14
|
+
ExpressKitErrorCode["NotAllowedToReviewLogs"] = "DEK11";
|
|
15
|
+
ExpressKitErrorCode["ThemeCheckedBeforeReactKitReady"] = "DEK12";
|
|
16
|
+
ExpressKitErrorCode["InvalidParameter"] = "DEK5";
|
|
17
|
+
ExpressKitErrorCode["MissingParameter"] = "DEK4";
|
|
18
|
+
// Server-to-server requests
|
|
19
|
+
ExpressKitErrorCode["NotConnected"] = "DEK14";
|
|
20
|
+
ExpressKitErrorCode["SelfSigned"] = "DEK15";
|
|
21
|
+
ExpressKitErrorCode["ResponseParseError"] = "DEK16";
|
|
22
|
+
ExpressKitErrorCode["SignedRequestUnparseable"] = "DEK28";
|
|
23
|
+
ExpressKitErrorCode["SignedRequestInvalidCollection"] = "DEK21";
|
|
24
|
+
ExpressKitErrorCode["SignedRequestInvalidCredential"] = "DEK23";
|
|
25
|
+
ExpressKitErrorCode["SignedRequestInvalidScope"] = "DEK22";
|
|
26
|
+
ExpressKitErrorCode["SignedRequestInvalidTimestamp"] = "DEK24";
|
|
27
|
+
ExpressKitErrorCode["SignedRequestInvalidSignature"] = "DEK25";
|
|
28
|
+
ExpressKitErrorCode["SignedRequestInvalidBody"] = "DEK26";
|
|
29
|
+
ExpressKitErrorCode["CrossServerNoCredentialsToSignWith"] = "DEK27";
|
|
30
|
+
ExpressKitErrorCode["CrossServerMissingSignedRequestInfo"] = "DEK29";
|
|
31
|
+
ExpressKitErrorCode["CrossServerNoCredentialEncodingSalt"] = "DEK30";
|
|
32
|
+
ExpressKitErrorCode["NoOauthLib"] = "DEK31";
|
|
33
|
+
ExpressKitErrorCode["NoCryptoLib"] = "DEK32";
|
|
34
|
+
ExpressKitErrorCode["InvalidCrossServerCredentialsFormat"] = "DEK33";
|
|
35
|
+
ExpressKitErrorCode["UnknownCrossServerError"] = "DEK34";
|
|
36
|
+
})(ExpressKitErrorCode || (ExpressKitErrorCode = {}));
|
|
37
|
+
exports.default = ExpressKitErrorCode;
|
|
38
|
+
//# sourceMappingURL=ExpressKitErrorCode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpressKitErrorCode.js","sourceRoot":"","sources":["../../src/types/ExpressKitErrorCode.ts"],"names":[],"mappings":";AAAA,6BAA6B;;AAE7B;;;GAGG;AACH,IAAK,mBA4BJ;AA5BD,WAAK,mBAAmB;IACtB,iBAAiB;IACjB,2CAAoB,CAAA;IACpB,sCAAe,CAAA;IACf,yCAAkB,CAAA;IAClB,uDAAgC,CAAA;IAChC,gEAAyC,CAAA;IACzC,gDAAyB,CAAA;IACzB,gDAAyB,CAAA;IAEzB,4BAA4B;IAC5B,6CAAsB,CAAA;IACtB,2CAAoB,CAAA;IACpB,mDAA4B,CAAA;IAC5B,yDAAkC,CAAA;IAClC,+DAAwC,CAAA;IACxC,+DAAwC,CAAA;IACxC,0DAAmC,CAAA;IACnC,8DAAuC,CAAA;IACvC,8DAAuC,CAAA;IACvC,yDAAkC,CAAA;IAClC,mEAA4C,CAAA;IAC5C,oEAA6C,CAAA;IAC7C,oEAA6C,CAAA;IAC7C,2CAAoB,CAAA;IACpB,4CAAqB,CAAA;IACrB,oEAA6C,CAAA;IAC7C,wDAAiC,CAAA;AACnC,CAAC,EA5BI,mBAAmB,KAAnB,mBAAmB,QA4BvB;AAED,kBAAe,mBAAmB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dce-expresskit",
|
|
3
|
+
"version": "4.0.0-beta.10",
|
|
4
|
+
"description": "Shared functions, helpers, and tools for Harvard DCE Express-based servers",
|
|
5
|
+
"main": "./lib/index.js",
|
|
6
|
+
"types": "./lib/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc --project ./tsconfig.json",
|
|
9
|
+
"gen-cross-server-secret": "npx tsx genEncodedSecret.ts",
|
|
10
|
+
"gen-cross-server-salt": "npx tsx genSalt.ts"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/harvard-edtech/dce-expresskit.git"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"Express",
|
|
18
|
+
"Harvard",
|
|
19
|
+
"DCE",
|
|
20
|
+
"Toolkit"
|
|
21
|
+
],
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@fortawesome/fontawesome-svg-core": "^6.7.2",
|
|
24
|
+
"@fortawesome/free-regular-svg-icons": "^6.7.2",
|
|
25
|
+
"@fortawesome/free-solid-svg-icons": "^6.7.2",
|
|
26
|
+
"@fortawesome/react-fontawesome": "^0.2.2",
|
|
27
|
+
"bootstrap": "^5.3.3",
|
|
28
|
+
"dce-reactkit": "^4.0.0-beta.2",
|
|
29
|
+
"react": "^19.0.0"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"caccl": "^x.x.x",
|
|
33
|
+
"dce-mango": "^x.x.x",
|
|
34
|
+
"express": "^4.21.2",
|
|
35
|
+
"express-session": "^1.18.1"
|
|
36
|
+
},
|
|
37
|
+
"author": "Gabe Abrams <gabeabrams@gmail.com>",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/harvard-edtech/dce-expresskit/issues"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/harvard-edtech/dce-expresskit#readme",
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/express": "^5.0.0",
|
|
45
|
+
"@types/express-session": "^1.18.1",
|
|
46
|
+
"@types/node": "^22.13.10",
|
|
47
|
+
"@types/oauth-signature": "^1.5.2",
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^5.59.9",
|
|
49
|
+
"@typescript-eslint/parser": "^5.59.9",
|
|
50
|
+
"eslint": "^8.42.0",
|
|
51
|
+
"typescript": "^5.8.2"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import ROUTE_PATH_PREFIX from './ROUTE_PATH_PREFIX';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Route for checking the status of the current user's
|
|
5
|
+
* access to log review
|
|
6
|
+
* @author Gabe Abrams
|
|
7
|
+
*/
|
|
8
|
+
const LOG_REVIEW_STATUS_ROUTE = `${ROUTE_PATH_PREFIX}/logs/access_allowed`;
|
|
9
|
+
|
|
10
|
+
export default LOG_REVIEW_STATUS_ROUTE;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An error with a code
|
|
3
|
+
* @author Gabe Abrams
|
|
4
|
+
*/
|
|
5
|
+
class ErrorWithCode extends Error {
|
|
6
|
+
code: string;
|
|
7
|
+
|
|
8
|
+
constructor(message: string, code: string) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = 'ErrorWithCode';
|
|
11
|
+
this.code = code;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default ErrorWithCode;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates the endpoint path for the given collection name
|
|
3
|
+
* @author Yuen Ler Chow
|
|
4
|
+
* @param collectionName the name of the collection
|
|
5
|
+
* @param [adminsOnly] true if the endpoint is for admins only
|
|
6
|
+
* @returns the endpoint path
|
|
7
|
+
*/
|
|
8
|
+
const generateEndpointPath = (collectionName: string, adminsOnly?: boolean) => {
|
|
9
|
+
// Determine prefix based on whether the endpoint is for admins only
|
|
10
|
+
const userPath = adminsOnly ? 'admin' : 'ttm';
|
|
11
|
+
|
|
12
|
+
// Return the endpoint path
|
|
13
|
+
return `/api/${userPath}/dce-reactkit/dbeditor/${collectionName}`;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default generateEndpointPath;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// Import express
|
|
2
|
+
import express from 'express';
|
|
3
|
+
|
|
4
|
+
// Import dce-reactkit
|
|
5
|
+
import {
|
|
6
|
+
ParamType,
|
|
7
|
+
} from 'dce-reactkit';
|
|
8
|
+
|
|
9
|
+
// Import shared helpers
|
|
10
|
+
import genRouteHandler from '../genRouteHandler';
|
|
11
|
+
import generateEndpointPath from './generateEndpointPath';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Interface for a collection in the database
|
|
15
|
+
* @author Yuen Ler Chow
|
|
16
|
+
*/
|
|
17
|
+
type DCEMangoCollection = {
|
|
18
|
+
/**
|
|
19
|
+
* Find all items in the collection that match the filter query
|
|
20
|
+
* @param filterQuery query for the filter
|
|
21
|
+
* @returns list of items that match the filter query
|
|
22
|
+
*/
|
|
23
|
+
find: (filterQuery: any) => Promise<any[]>,
|
|
24
|
+
/**
|
|
25
|
+
* Insert an item into the collection
|
|
26
|
+
* @param item the item to insert
|
|
27
|
+
*/
|
|
28
|
+
insert: (item: any) => Promise<void>,
|
|
29
|
+
/**
|
|
30
|
+
* Delete an item in the collection
|
|
31
|
+
* @param id the id of the item to delete
|
|
32
|
+
*/
|
|
33
|
+
delete: (filterQuery: { id: string }) => Promise<void>,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Add all routes for the DBEditor
|
|
38
|
+
* @author Yuen Ler Chow
|
|
39
|
+
* @param opts object containing all arguments
|
|
40
|
+
* @param opts.app express app to add routes too
|
|
41
|
+
* @param opts.collectionName the name of the collection
|
|
42
|
+
* @param opts.adminsOnly true if the endpoint is for admins only
|
|
43
|
+
* @param opts.collection dce-mango db collection
|
|
44
|
+
*/
|
|
45
|
+
const addDBEditorEndpoints = (
|
|
46
|
+
opts: {
|
|
47
|
+
app: express.Application,
|
|
48
|
+
collectionName: string,
|
|
49
|
+
adminsOnly: boolean,
|
|
50
|
+
collection: DCEMangoCollection,
|
|
51
|
+
},
|
|
52
|
+
) => {
|
|
53
|
+
const {
|
|
54
|
+
app,
|
|
55
|
+
collectionName,
|
|
56
|
+
adminsOnly,
|
|
57
|
+
collection,
|
|
58
|
+
} = opts;
|
|
59
|
+
|
|
60
|
+
// Generate the endpoint path
|
|
61
|
+
const endpointPath = generateEndpointPath(collectionName, adminsOnly);
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* List all items in the collection
|
|
65
|
+
* @author Yuen Ler Chow
|
|
66
|
+
* @returns {any[]} the list of items in the collection
|
|
67
|
+
*/
|
|
68
|
+
app.get(
|
|
69
|
+
endpointPath,
|
|
70
|
+
genRouteHandler({
|
|
71
|
+
paramTypes: {
|
|
72
|
+
filterQuery: ParamType.JSONOptional,
|
|
73
|
+
},
|
|
74
|
+
handler: async ({ params }) => {
|
|
75
|
+
const filterQuery = params.filterQuery ?? {};
|
|
76
|
+
const categories = await collection.find(filterQuery);
|
|
77
|
+
return categories;
|
|
78
|
+
},
|
|
79
|
+
}),
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Create a new item in the collection
|
|
84
|
+
* @author Yuen Ler Chow
|
|
85
|
+
* @param {any} item the item to create
|
|
86
|
+
*/
|
|
87
|
+
app.post(
|
|
88
|
+
endpointPath,
|
|
89
|
+
genRouteHandler({
|
|
90
|
+
paramTypes: {
|
|
91
|
+
item: ParamType.JSON,
|
|
92
|
+
},
|
|
93
|
+
handler: async ({
|
|
94
|
+
params,
|
|
95
|
+
}) => {
|
|
96
|
+
// Destructure params
|
|
97
|
+
const {
|
|
98
|
+
item,
|
|
99
|
+
} = params;
|
|
100
|
+
|
|
101
|
+
await collection.insert(item);
|
|
102
|
+
},
|
|
103
|
+
}),
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Remove an item from the collection by id
|
|
108
|
+
* @author Yuen Ler Chow
|
|
109
|
+
*/
|
|
110
|
+
app.delete(
|
|
111
|
+
`${endpointPath}/:id`,
|
|
112
|
+
genRouteHandler({
|
|
113
|
+
paramTypes: {
|
|
114
|
+
id: ParamType.String,
|
|
115
|
+
},
|
|
116
|
+
handler: async ({
|
|
117
|
+
params,
|
|
118
|
+
}) => {
|
|
119
|
+
// Destructure params
|
|
120
|
+
const {
|
|
121
|
+
id,
|
|
122
|
+
} = params;
|
|
123
|
+
|
|
124
|
+
await collection.delete({ id });
|
|
125
|
+
},
|
|
126
|
+
}),
|
|
127
|
+
);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export default addDBEditorEndpoints;
|