dce-expresskit 4.0.0-beta-logreviewer.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.
Files changed (99) hide show
  1. package/.eslintrc.js +93 -0
  2. package/LICENSE +21 -0
  3. package/README.md +17 -0
  4. package/genEncodedSecret.ts +107 -0
  5. package/genSalt.ts +15 -0
  6. package/lib/constants/LOG_REVIEW_PAGE_SIZE.d.ts +6 -0
  7. package/lib/constants/LOG_REVIEW_PAGE_SIZE.js +9 -0
  8. package/lib/constants/LOG_REVIEW_PAGE_SIZE.js.map +1 -0
  9. package/lib/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.d.ts +6 -0
  10. package/lib/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.js +13 -0
  11. package/lib/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.js.map +1 -0
  12. package/lib/constants/LOG_REVIEW_STATUS_ROUTE.d.ts +7 -0
  13. package/lib/constants/LOG_REVIEW_STATUS_ROUTE.js +14 -0
  14. package/lib/constants/LOG_REVIEW_STATUS_ROUTE.js.map +1 -0
  15. package/lib/constants/LOG_ROUTE_PATH.d.ts +6 -0
  16. package/lib/constants/LOG_ROUTE_PATH.js +13 -0
  17. package/lib/constants/LOG_ROUTE_PATH.js.map +1 -0
  18. package/lib/constants/ROUTE_PATH_PREFIX.d.ts +6 -0
  19. package/lib/constants/ROUTE_PATH_PREFIX.js +9 -0
  20. package/lib/constants/ROUTE_PATH_PREFIX.js.map +1 -0
  21. package/lib/errors/ErrorWithCode.d.ts +9 -0
  22. package/lib/errors/ErrorWithCode.js +33 -0
  23. package/lib/errors/ErrorWithCode.js.map +1 -0
  24. package/lib/helpers/addDBEditorEndpoints/generateEndpointPath.d.ts +9 -0
  25. package/lib/helpers/addDBEditorEndpoints/generateEndpointPath.js +17 -0
  26. package/lib/helpers/addDBEditorEndpoints/generateEndpointPath.js.map +1 -0
  27. package/lib/helpers/addDBEditorEndpoints/index.d.ts +41 -0
  28. package/lib/helpers/addDBEditorEndpoints/index.js +134 -0
  29. package/lib/helpers/addDBEditorEndpoints/index.js.map +1 -0
  30. package/lib/helpers/dataSigner.d.ts +40 -0
  31. package/lib/helpers/dataSigner.js +242 -0
  32. package/lib/helpers/dataSigner.js.map +1 -0
  33. package/lib/helpers/genRouteHandler.d.ts +75 -0
  34. package/lib/helpers/genRouteHandler.js +662 -0
  35. package/lib/helpers/genRouteHandler.js.map +1 -0
  36. package/lib/helpers/getLogReviewerLogs.d.ts +27 -0
  37. package/lib/helpers/getLogReviewerLogs.js +238 -0
  38. package/lib/helpers/getLogReviewerLogs.js.map +1 -0
  39. package/lib/helpers/handleError.d.ts +18 -0
  40. package/lib/helpers/handleError.js +51 -0
  41. package/lib/helpers/handleError.js.map +1 -0
  42. package/lib/helpers/handleSuccess.d.ts +8 -0
  43. package/lib/helpers/handleSuccess.js +20 -0
  44. package/lib/helpers/handleSuccess.js.map +1 -0
  45. package/lib/helpers/initCrossServerCredentialCollection.d.ts +11 -0
  46. package/lib/helpers/initCrossServerCredentialCollection.js +15 -0
  47. package/lib/helpers/initCrossServerCredentialCollection.js.map +1 -0
  48. package/lib/helpers/initLogCollection.d.ts +11 -0
  49. package/lib/helpers/initLogCollection.js +26 -0
  50. package/lib/helpers/initLogCollection.js.map +1 -0
  51. package/lib/helpers/initServer.d.ts +45 -0
  52. package/lib/helpers/initServer.js +292 -0
  53. package/lib/helpers/initServer.js.map +1 -0
  54. package/lib/helpers/parseUserAgent.d.ts +17 -0
  55. package/lib/helpers/parseUserAgent.js +108 -0
  56. package/lib/helpers/parseUserAgent.js.map +1 -0
  57. package/lib/helpers/visitEndpointOnAnotherServer/index.d.ts +18 -0
  58. package/lib/helpers/visitEndpointOnAnotherServer/index.js +89 -0
  59. package/lib/helpers/visitEndpointOnAnotherServer/index.js.map +1 -0
  60. package/lib/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.d.ts +23 -0
  61. package/lib/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.js +236 -0
  62. package/lib/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.js.map +1 -0
  63. package/lib/html/genErrorPage.d.ts +19 -0
  64. package/lib/html/genErrorPage.js +27 -0
  65. package/lib/html/genErrorPage.js.map +1 -0
  66. package/lib/html/genInfoPage.d.ts +13 -0
  67. package/lib/html/genInfoPage.js +16 -0
  68. package/lib/html/genInfoPage.js.map +1 -0
  69. package/lib/index.d.ts +11 -0
  70. package/lib/index.js +68 -0
  71. package/lib/index.js.map +1 -0
  72. package/lib/types/CrossServerCredential.d.ts +11 -0
  73. package/lib/types/CrossServerCredential.js +3 -0
  74. package/lib/types/CrossServerCredential.js.map +1 -0
  75. package/lib/types/ExpressKitErrorCode.d.ts +31 -0
  76. package/lib/types/ExpressKitErrorCode.js +38 -0
  77. package/lib/types/ExpressKitErrorCode.js.map +1 -0
  78. package/package.json +53 -0
  79. package/src/constants/LOG_REVIEW_PAGE_SIZE.ts +7 -0
  80. package/src/errors/ErrorWithCode.tsx +15 -0
  81. package/src/helpers/addDBEditorEndpoints/generateEndpointPath.ts +16 -0
  82. package/src/helpers/addDBEditorEndpoints/index.ts +130 -0
  83. package/src/helpers/dataSigner.ts +319 -0
  84. package/src/helpers/genRouteHandler.ts +920 -0
  85. package/src/helpers/getLogReviewerLogs.ts +259 -0
  86. package/src/helpers/handleError.ts +66 -0
  87. package/src/helpers/handleSuccess.ts +18 -0
  88. package/src/helpers/initCrossServerCredentialCollection.ts +19 -0
  89. package/src/helpers/initLogCollection.ts +30 -0
  90. package/src/helpers/initServer.ts +283 -0
  91. package/src/helpers/parseUserAgent.ts +108 -0
  92. package/src/helpers/visitEndpointOnAnotherServer/index.ts +70 -0
  93. package/src/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.ts +257 -0
  94. package/src/html/genErrorPage.ts +144 -0
  95. package/src/html/genInfoPage.ts +101 -0
  96. package/src/index.ts +125 -0
  97. package/src/types/CrossServerCredential.ts +16 -0
  98. package/src/types/ExpressKitErrorCode.ts +37 -0
  99. package/tsconfig.json +19 -0
@@ -0,0 +1,236 @@
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 __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ var _a;
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ // Import libs
44
+ var qs_1 = __importDefault(require("qs"));
45
+ // Import dce-reactkit
46
+ var dce_reactkit_1 = require("dce-reactkit");
47
+ // Import data signer
48
+ var dataSigner_1 = require("../dataSigner");
49
+ // Import shared types
50
+ var ExpressKitErrorCode_1 = __importDefault(require("../../types/ExpressKitErrorCode"));
51
+ /*------------------------------------------------------------------------*/
52
+ /* ----------------------------- Credentials ---------------------------- */
53
+ /*------------------------------------------------------------------------*/
54
+ /*
55
+ DCEKIT_CROSS_SERVER_CREDENTIALS format:
56
+ |host:key:secret||host:key:secret|...
57
+ */
58
+ var credentials = (((_a = process.env.DCEKIT_CROSS_SERVER_CREDENTIALS) !== null && _a !== void 0 ? _a : '')
59
+ // Replace multiple | with a single one
60
+ .replace(/\|+/g, '|')
61
+ // Split by |
62
+ .split('|')
63
+ // Remove empty strings
64
+ .filter(function (str) {
65
+ return str.trim().length > 0;
66
+ })
67
+ // Process each credential
68
+ .map(function (str) {
69
+ // Split by :
70
+ var parts = str.split(':');
71
+ // Check for errors
72
+ if (parts.length !== 3) {
73
+ throw new dce_reactkit_1.ErrorWithCode('Invalid DCEKIT_CROSS_SERVER_CREDENTIALS format. Each credential must be in the format |host:key:secret|', ExpressKitErrorCode_1.default.InvalidCrossServerCredentialsFormat);
74
+ }
75
+ // Return the credential
76
+ return {
77
+ host: parts[0].trim(),
78
+ key: parts[1].trim(),
79
+ secret: parts[2].trim(),
80
+ };
81
+ }));
82
+ /*------------------------------------------------------------------------*/
83
+ /* ------------------------------- Helpers ------------------------------ */
84
+ /*------------------------------------------------------------------------*/
85
+ /**
86
+ * Get the credential to use for the request to another server
87
+ * @author Gabe Abrams
88
+ * @param host the host of the other server
89
+ * @return the credential to use
90
+ */
91
+ var getCrossServerCredential = function (host) {
92
+ // Find the credential
93
+ var credential = credentials.find(function (cred) {
94
+ return cred.host.toLowerCase() === host.toLowerCase();
95
+ });
96
+ if (!credential) {
97
+ throw new dce_reactkit_1.ErrorWithCode('Cannot send cross-server signed request there was no credential that matched the host that the request is being sent to.', ExpressKitErrorCode_1.default.CrossServerNoCredentialsToSignWith);
98
+ }
99
+ // Return credential
100
+ return credential;
101
+ };
102
+ /*------------------------------------------------------------------------*/
103
+ /* -------------------------------- Main -------------------------------- */
104
+ /*------------------------------------------------------------------------*/
105
+ /**
106
+ * Sends and retries an http request
107
+ * @author Gabriel Abrams
108
+ * @param opts object containing all arguments
109
+ * @param opts.path path to send request to
110
+ * @param [opts.host] host to send request to
111
+ * @param [opts.method=GET] http method to use
112
+ * @param [opts.params] body/data to include in the request
113
+ * @param [opts.responseType=JSON] expected response type
114
+ * @returns { body, status, headers } on success
115
+ */
116
+ var sendServerToServerRequest = function (opts) { return __awaiter(void 0, void 0, void 0, function () {
117
+ var method, params, credential, stringifiedParams, query, url, headers, data, encodedData, response, responseHeaders_1, responseBody, err_1, err_2;
118
+ var _a;
119
+ return __generator(this, function (_b) {
120
+ switch (_b.label) {
121
+ case 0:
122
+ method = (opts.method || 'GET');
123
+ if (opts.params) {
124
+ params = {};
125
+ Object.entries(opts.params).forEach(function (_a) {
126
+ var key = _a[0], val = _a[1];
127
+ if (typeof val === 'object' && !Array.isArray(val)) {
128
+ params[key] = JSON.stringify(val);
129
+ }
130
+ else {
131
+ params[key] = val;
132
+ }
133
+ });
134
+ }
135
+ credential = getCrossServerCredential(opts.host);
136
+ return [4 /*yield*/, (0, dataSigner_1.signRequest)({
137
+ method: opts.method,
138
+ path: opts.path,
139
+ params: params !== null && params !== void 0 ? params : {},
140
+ key: credential.key,
141
+ secret: credential.secret,
142
+ })];
143
+ case 1:
144
+ // Sign the request, get new params
145
+ params = _b.sent();
146
+ stringifiedParams = qs_1.default.stringify(params || {}, {
147
+ encodeValuesOnly: true,
148
+ arrayFormat: 'brackets',
149
+ });
150
+ query = (method === 'GET' ? "?".concat(stringifiedParams) : '');
151
+ if (!opts.host) {
152
+ // No host included at all. Just send to a path
153
+ url = "".concat(opts.path).concat(query);
154
+ }
155
+ else {
156
+ url = "https://".concat(opts.host).concat(opts.path).concat(query);
157
+ }
158
+ headers = {};
159
+ data = null;
160
+ if (!headers['Content-Type']) {
161
+ // Form encoded
162
+ headers['Content-Type'] = 'application/x-www-form-urlencoded';
163
+ // Add data if applicable
164
+ data = (method !== 'GET' ? stringifiedParams : null);
165
+ }
166
+ else {
167
+ // JSON encode
168
+ data = params;
169
+ }
170
+ if (data) {
171
+ if (headers['Content-Type'] === 'application/x-www-form-urlencoded') {
172
+ encodedData = new URLSearchParams(params);
173
+ }
174
+ else {
175
+ encodedData = JSON.stringify(data);
176
+ }
177
+ }
178
+ _b.label = 2;
179
+ case 2:
180
+ _b.trys.push([2, 11, , 12]);
181
+ return [4 /*yield*/, fetch(url, {
182
+ method: method,
183
+ mode: 'cors',
184
+ headers: headers !== null && headers !== void 0 ? headers : {},
185
+ body: ((method !== 'GET' && encodedData)
186
+ ? encodedData
187
+ : undefined),
188
+ redirect: 'follow',
189
+ })];
190
+ case 3:
191
+ response = _b.sent();
192
+ responseHeaders_1 = {};
193
+ response.headers.forEach(function (value, key) {
194
+ responseHeaders_1[key] = value;
195
+ });
196
+ _b.label = 4;
197
+ case 4:
198
+ _b.trys.push([4, 9, , 10]);
199
+ responseBody = void 0;
200
+ if (!(opts.responseType
201
+ && opts.responseType === 'Text')) return [3 /*break*/, 6];
202
+ return [4 /*yield*/, response.text()];
203
+ case 5:
204
+ // Response type is text
205
+ responseBody = _b.sent();
206
+ return [3 /*break*/, 8];
207
+ case 6: return [4 /*yield*/, response.json()];
208
+ case 7:
209
+ // Response type is JSON
210
+ responseBody = _b.sent();
211
+ _b.label = 8;
212
+ case 8:
213
+ // Return response
214
+ return [2 /*return*/, {
215
+ body: responseBody,
216
+ status: response.status,
217
+ headers: responseHeaders_1,
218
+ }];
219
+ case 9:
220
+ err_1 = _b.sent();
221
+ throw new dce_reactkit_1.ErrorWithCode("Failed to parse response as ".concat(opts.responseType, ": ").concat(err_1 === null || err_1 === void 0 ? void 0 : err_1.message), ExpressKitErrorCode_1.default.ResponseParseError);
222
+ case 10: return [3 /*break*/, 12];
223
+ case 11:
224
+ err_2 = _b.sent();
225
+ // Self-signed certificate error:
226
+ if ((_a = err_2 === null || err_2 === void 0 ? void 0 : err_2.message) === null || _a === void 0 ? void 0 : _a.includes('self signed certificate')) {
227
+ throw new dce_reactkit_1.ErrorWithCode('We refused to send a request because the receiver has self-signed certificates.', ExpressKitErrorCode_1.default.SelfSigned);
228
+ }
229
+ // No tries left
230
+ throw new dce_reactkit_1.ErrorWithCode("We encountered an error when trying to send a network request. If this issue persists, contact an admin. Error: ".concat(err_2 === null || err_2 === void 0 ? void 0 : err_2.message), ExpressKitErrorCode_1.default.NotConnected);
231
+ case 12: return [2 /*return*/];
232
+ }
233
+ });
234
+ }); };
235
+ exports.default = sendServerToServerRequest;
236
+ //# sourceMappingURL=sendServerToServerRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sendServerToServerRequest.js","sourceRoot":"","sources":["../../../src/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAc;AACd,0CAAoB;AAEpB,sBAAsB;AACtB,6CAEsB;AAEtB,qBAAqB;AACrB,4CAA4C;AAE5C,sBAAsB;AACtB,wFAAkE;AAElE,4E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AC;gBACJ,CAAC;gBAED,gBAAgB;gBAChB,MAAM,IAAI,4BAAa,CACrB,0HAAoH,KAAW,aAAX,KAAG,uBAAH,KAAG,CAAU,OAAO,CAAE,EAC1I,6BAAmB,CAAC,YAAY,CACjC,CAAC;;;;KAEL,CAAC;AAEF,kBAAe,yBAAyB,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Generate a static error page
3
+ * @author Gabe Abrams
4
+ * @param opts object containing all arguments
5
+ * @param [opts.title=An Error Occurred] title of the error box
6
+ * @param [opts.description=An unknown server error occurred. Please contact support.]
7
+ * a human-readable description of the error
8
+ * @param [opts.code=ReactKitErrorCode.NoCode] error code to show
9
+ * @param [opts.pageTitle=opts.title] title of the page/tab if it differs from
10
+ * the title of the error
11
+ * @returns html of the page
12
+ */
13
+ declare const genErrorPage: (opts?: {
14
+ title?: string;
15
+ description?: string;
16
+ code?: string;
17
+ pageTitle?: string;
18
+ }) => string;
19
+ export default genErrorPage;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // Import dce-reactkit
4
+ var dce_reactkit_1 = require("dce-reactkit");
5
+ /**
6
+ * Generate a static error page
7
+ * @author Gabe Abrams
8
+ * @param opts object containing all arguments
9
+ * @param [opts.title=An Error Occurred] title of the error box
10
+ * @param [opts.description=An unknown server error occurred. Please contact support.]
11
+ * a human-readable description of the error
12
+ * @param [opts.code=ReactKitErrorCode.NoCode] error code to show
13
+ * @param [opts.pageTitle=opts.title] title of the page/tab if it differs from
14
+ * the title of the error
15
+ * @returns html of the page
16
+ */
17
+ var genErrorPage = function (opts) {
18
+ var _a, _b, _c, _d;
19
+ if (opts === void 0) { opts = {}; }
20
+ var title = ((_a = opts.title) !== null && _a !== void 0 ? _a : 'An Error Occurred');
21
+ var pageTitle = ((_b = opts.pageTitle) !== null && _b !== void 0 ? _b : title);
22
+ var description = ((_c = opts.description) !== null && _c !== void 0 ? _c : 'An unknown server error occurred. Please contact support.');
23
+ var code = ((_d = opts.code) !== null && _d !== void 0 ? _d : dce_reactkit_1.ReactKitErrorCode.NoCode);
24
+ return "\n<head>\n <!-- Metadata -->\n <meta\n name=\"viewport\"\n content=\"width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0\"\n >\n\n <!-- Title -->\n <title>".concat(pageTitle, "</title>\n\n <!-- Bootstrap -->\n <link\n rel=\"stylesheet\"\n href=\"https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.1/css/bootstrap.min.css\"\n integrity=\"sha512-siwe/oXMhSjGCwLn+scraPOWrJxHlUgMBMZXdPe2Tnk3I0x3ESCoLz7WZ5NTH6SZrywMY+PB1cjyqJ5jAluCOg==\"\n crossorigin=\"anonymous\"\n referrerpolicy=\"no-referrer\"\n />\n <script\n src=\"https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.1/js/bootstrap.min.js\"\n integrity=\"sha512-vyRAVI0IEm6LI/fVSv/Wq/d0KUfrg3hJq2Qz5FlfER69sf3ZHlOrsLriNm49FxnpUGmhx+TaJKwJ+ByTLKT+Yg==\"\n crossorigin=\"anonymous\"\n referrerpolicy=\"no-referrer\"\n ></script>\n\n <!-- FontAwesome -->\n <link\n rel=\"stylesheet\"\n href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css\"\n integrity=\"sha512-xh6O/CkQoPOWDdYTDqeRdPCVd1SpvCA9XXcUnZS2FmJNp1coAFzvtCN9BmamE+4aHK8yyUHUSCcJHgXloTyT2A==\"\n crossorigin=\"anonymous\"\n referrerpolicy=\"no-referrer\"\n />\n\n <!-- Style -->\n <style>\n .DCEReactKit-pop-in {\n animation-name: DCEReactKit-pop-in;\n animation-duration: 0.5s;\n animation-iteration-count: 1;\n animation-timing-function: ease-out;\n animation-fill-mode: both;\n\n transform-origin: center;\n }\n\n @keyframes DCEReactKit-pop-in {\n 0% {\n opacity: 0;\n transform: scale(0.9);\n }\n 100% {\n opacity: 1;\n transform: scale(1);\n }\n }\n\n .DCEReactKit-slide-in {\n animation-name: DCEReactKit-slide-in;\n animation-duration: 1s;\n animation-iteration-count: 1;\n animation-timing-function: ease-out;\n animation-fill-mode: both;\n animation-delay: 0.2s;\n }\n\n @keyframes DCEReactKit-slide-in {\n 0% {\n opacity: 0;\n transform: translate(0, 0.3em);\n }\n 100% {\n opacity: 1;\n transform: translate(0, 0);\n }\n }\n </style>\n</head>\n\n<!-- Body -->\n<body class=\"bg-dark text-center pt-3 ps-3 pe-3\">\n <!-- Alert -->\n <div\n class=\"DCEReactKit-pop-in alert alert-warning d-inline-block\"\n style=\"width: 50em; max-width: 100%\"\n >\n <!-- Title -->\n <h2>\n <i class=\"me-1 fa-solid fa-triangle-exclamation\"></i>\n ").concat(title, "\n </h2>\n <!-- Description -->\n <div>\n ").concat(description, "\n </div>\n </div>\n\n <!-- Error Code -->\n <div class=\"DCEReactKit-slide-in text-light\">\n <strong>\n Error Code:\n </strong>\n ").concat(code, "\n </div>\n</body>\n ");
25
+ };
26
+ exports.default = genErrorPage;
27
+ //# sourceMappingURL=genErrorPage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"genErrorPage.js","sourceRoot":"","sources":["../../src/html/genErrorPage.ts"],"names":[],"mappings":";;AAAA,sBAAsB;AACtB,6CAAiD;AAKjD;;;;;;;;;;;GAWG;AACH,IAAM,YAAY,GAAG,UACnB,IAKM;;IALN,qBAAA,EAAA,SAKM;IAEN,IAAM,KAAK,GAAG,CAAC,MAAA,IAAI,CAAC,KAAK,mCAAI,mBAAmB,CAAC,CAAC;IAClD,IAAM,SAAS,GAAG,CAAC,MAAA,IAAI,CAAC,SAAS,mCAAI,KAAK,CAAC,CAAC;IAC5C,IAAM,WAAW,GAAG,CAClB,MAAA,IAAI,CAAC,WAAW,mCACb,2DAA2D,CAC/D,CAAC;IACF,IAAM,IAAI,GAAG,CAAC,MAAA,IAAI,CAAC,IAAI,mCAAI,gCAAiB,CAAC,MAAM,CAAC,CAAC;IAErD,OAAO,2MASE,SAAS,uuEAiFZ,KAAK,qEAIL,WAAW,qKASb,IAAI,4BAGP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,YAAY,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Generate a static info page
3
+ * @author Gabe Abrams
4
+ * @param opts object containing all arguments
5
+ * @param opts.title title of the info box
6
+ * @param opts.body a human-readable text body for the info alert
7
+ * @returns the HTML for the info page
8
+ */
9
+ declare const genInfoPage: (opts: {
10
+ title: string;
11
+ body: string;
12
+ }) => string;
13
+ export default genInfoPage;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Generate a static info page
5
+ * @author Gabe Abrams
6
+ * @param opts object containing all arguments
7
+ * @param opts.title title of the info box
8
+ * @param opts.body a human-readable text body for the info alert
9
+ * @returns the HTML for the info page
10
+ */
11
+ var genInfoPage = function (opts) {
12
+ var title = opts.title, body = opts.body;
13
+ return "\n<head>\n <!-- Metadata -->\n <meta\n name=\"viewport\"\n content=\"width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0\"\n >\n\n <!-- Title -->\n <title>".concat(title, "</title>\n\n <!-- Bootstrap -->\n <link\n rel=\"stylesheet\"\n href=\"https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.1/css/bootstrap.min.css\"\n integrity=\"sha512-siwe/oXMhSjGCwLn+scraPOWrJxHlUgMBMZXdPe2Tnk3I0x3ESCoLz7WZ5NTH6SZrywMY+PB1cjyqJ5jAluCOg==\"\n crossorigin=\"anonymous\"\n referrerpolicy=\"no-referrer\"\n />\n <script\n src=\"https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.1/js/bootstrap.min.js\"\n integrity=\"sha512-vyRAVI0IEm6LI/fVSv/Wq/d0KUfrg3hJq2Qz5FlfER69sf3ZHlOrsLriNm49FxnpUGmhx+TaJKwJ+ByTLKT+Yg==\"\n crossorigin=\"anonymous\"\n referrerpolicy=\"no-referrer\"\n ></script>\n\n <!-- FontAwesome -->\n <link\n rel=\"stylesheet\"\n href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css\"\n integrity=\"sha512-xh6O/CkQoPOWDdYTDqeRdPCVd1SpvCA9XXcUnZS2FmJNp1coAFzvtCN9BmamE+4aHK8yyUHUSCcJHgXloTyT2A==\"\n crossorigin=\"anonymous\"\n referrerpolicy=\"no-referrer\"\n />\n\n <!-- Style -->\n <style>\n .DCEReactKit-pop-in {\n animation-name: DCEReactKit-pop-in;\n animation-duration: 0.5s;\n animation-iteration-count: 1;\n animation-timing-function: ease-out;\n animation-fill-mode: both;\n\n transform-origin: center;\n }\n\n @keyframes DCEReactKit-pop-in {\n 0% {\n opacity: 0;\n transform: scale(0.9);\n }\n 100% {\n opacity: 1;\n transform: scale(1);\n }\n }\n </style>\n</head>\n\n<!-- Body -->\n<body class=\"bg-dark text-center pt-3 ps-3 pe-3\">\n <!-- Alert -->\n <div\n class=\"DCEReactKit-pop-in alert alert-info d-inline-block\"\n style=\"width: 50em; max-width: 100%\"\n >\n <!-- Title -->\n <h2>\n <i class=\"me-1 fa-solid fa-circle-info\"></i>\n ").concat(title, "\n </h2>\n <!-- Body -->\n <div>\n ").concat(body, "\n </div>\n </div>\n</body>\n ");
14
+ };
15
+ exports.default = genInfoPage;
16
+ //# sourceMappingURL=genInfoPage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"genInfoPage.js","sourceRoot":"","sources":["../../src/html/genInfoPage.ts"],"names":[],"mappings":";;AAAA;;;;;;;GAOG;AACH,IAAM,WAAW,GAAG,UAClB,IAGC;IAGC,IAAA,KAAK,GAEH,IAAI,MAFD,EACL,IAAI,GACF,IAAI,KADF,CACG;IAET,OAAO,2MASE,KAAK,owDA6DR,KAAK,8DAIL,IAAI,wCAIT,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,WAAW,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, extractProp, compareArraysByProp, getLocalTimeInfo, genCommaList, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, ErrorWithCode, ParamType } from 'dce-reactkit';
2
+ import initCrossServerCredentialCollection from './helpers/initCrossServerCredentialCollection';
3
+ import initLogCollection from './helpers/initLogCollection';
4
+ import initServer from './helpers/initServer';
5
+ import genRouteHandler from './helpers/genRouteHandler';
6
+ import handleError from './helpers/handleError';
7
+ import handleSuccess from './helpers/handleSuccess';
8
+ import addDBEditorEndpoints from './helpers/addDBEditorEndpoints';
9
+ import visitEndpointOnAnotherServer from './helpers/visitEndpointOnAnotherServer';
10
+ import CrossServerCredential from './types/CrossServerCredential';
11
+ export { ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, extractProp, compareArraysByProp, genCommaList, getLocalTimeInfo, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, initCrossServerCredentialCollection, addDBEditorEndpoints, visitEndpointOnAnotherServer, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, CrossServerCredential, ParamType, };
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
@@ -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,mGAr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;AAoDlD,wBApDK,uBAAa,CAoDL;AAnDf,wFAAkE;AAsDhE,+BAtDK,8BAAoB,CAsDL;AArDtB,wGAAkF;AAsDhF,uCAtDK,sCAA4B,CAsDL"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Single cross-server credential
3
+ * @author Gabe Abrams
4
+ */
5
+ type CrossServerCredential = {
6
+ description: string;
7
+ key: string;
8
+ encodedeSecret: string;
9
+ scopes: string[];
10
+ };
11
+ export default CrossServerCredential;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=CrossServerCredential.js.map
@@ -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-logreviewer.1",
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-logreviewer.1",
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,7 @@
1
+ /**
2
+ * Log reviewer page size
3
+ * @author Yuen Ler Chow
4
+ */
5
+ const LOG_REVIEW_PAGE_SIZE = 100;
6
+
7
+ export default LOG_REVIEW_PAGE_SIZE;
@@ -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;