dce-expresskit 4.0.0-beta.2
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 +84 -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 +231 -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 +43 -0
- package/lib/helpers/initServer.js +297 -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 +52 -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 +296 -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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genRouteHandler.js","sourceRoot":"","sources":["../../src/helpers/genRouteHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sBAAsB;AACtB,6CAcsB;AAEtB,eAAe;AACf,uCAA6C;AAE7C,yBAAyB;AACzB,2CAEsB;AAEtB,sBAAsB;AACtB,qFAA+D;AAE/D,iBAAiB;AACjB,8DAAwC;AACxC,kEAA4C;AAC5C,sEAAgD;AAChD,oEAA8C;AAC9C,oEAA8C;AAC9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
|
+
* @author Gabe Abrams
|
|
4
|
+
* @param res express response
|
|
5
|
+
* @param error error info
|
|
6
|
+
* @param opts.err the error to send to the client
|
|
7
|
+
* or the error message
|
|
8
|
+
* @param [opts.code] an error code (only used if err.code is not
|
|
9
|
+
* included)
|
|
10
|
+
* @param [opts.status=500] the https status code to use
|
|
11
|
+
* defined)
|
|
12
|
+
*/
|
|
13
|
+
declare const handleError: (res: any, error: ({
|
|
14
|
+
message: any;
|
|
15
|
+
code?: string;
|
|
16
|
+
status?: number;
|
|
17
|
+
} | Error | string | any)) => undefined;
|
|
18
|
+
export default handleError;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// Import shared types
|
|
4
|
+
var dce_reactkit_1 = require("dce-reactkit");
|
|
5
|
+
/**
|
|
6
|
+
* Handle an error and respond to the client
|
|
7
|
+
* @author Gabe Abrams
|
|
8
|
+
* @param res express response
|
|
9
|
+
* @param error error info
|
|
10
|
+
* @param opts.err the error to send to the client
|
|
11
|
+
* or the error message
|
|
12
|
+
* @param [opts.code] an error code (only used if err.code is not
|
|
13
|
+
* included)
|
|
14
|
+
* @param [opts.status=500] the https status code to use
|
|
15
|
+
* defined)
|
|
16
|
+
*/
|
|
17
|
+
var handleError = function (res, error) {
|
|
18
|
+
// Get the error message
|
|
19
|
+
var message;
|
|
20
|
+
if (error && error.message) {
|
|
21
|
+
message = (error.message || 'An unknown error occurred.');
|
|
22
|
+
}
|
|
23
|
+
else if (typeof error === 'string') {
|
|
24
|
+
message = (error.trim().length > 0
|
|
25
|
+
? error
|
|
26
|
+
: 'An unknown error occurred.');
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
message = 'An unknown error occurred.';
|
|
30
|
+
}
|
|
31
|
+
// Get the error code
|
|
32
|
+
var code = (error.code || dce_reactkit_1.ReactKitErrorCode.NoCode);
|
|
33
|
+
// Get the status code
|
|
34
|
+
var status = (error.status || 500);
|
|
35
|
+
// Respond to user
|
|
36
|
+
res
|
|
37
|
+
// Set the http status code
|
|
38
|
+
.status(status)
|
|
39
|
+
// Send a JSON response
|
|
40
|
+
.json({
|
|
41
|
+
// Error message
|
|
42
|
+
message: message,
|
|
43
|
+
// Error code
|
|
44
|
+
code: code,
|
|
45
|
+
// Success = false flag so client can detect server-side errors
|
|
46
|
+
success: false,
|
|
47
|
+
});
|
|
48
|
+
return undefined;
|
|
49
|
+
};
|
|
50
|
+
exports.default = handleError;
|
|
51
|
+
//# sourceMappingURL=handleError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleError.js","sourceRoot":"","sources":["../../src/helpers/handleError.ts"],"names":[],"mappings":";;AAAA,sBAAsB;AACtB,6CAAiD;AAGjD;;;;;;;;;;;GAWG;AACH,IAAM,WAAW,GAAG,UAClB,GAAQ,EACR,KASC;IAED,wBAAwB;IACxB,IAAI,OAAO,CAAC;IACZ,IAAI,KAAK,IAAK,KAAa,CAAC,OAAO,EAAE,CAAC;QACpC,OAAO,GAAG,CAAC,KAAK,CAAC,OAAO,IAAI,4BAA4B,CAAC,CAAC;IAC5D,CAAC;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACrC,OAAO,GAAG,CACR,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;YACrB,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,4BAA4B,CACjC,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,4BAA4B,CAAC;IACzC,CAAC;IAED,qBAAqB;IACrB,IAAM,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,gCAAiB,CAAC,MAAM,CAAC,CAAC;IAEtD,sBAAsB;IACtB,IAAM,MAAM,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC;IAErC,kBAAkB;IAClB,GAAG;QACD,2BAA2B;SAC1B,MAAM,CAAC,MAAM,CAAC;QACf,uBAAuB;SACtB,IAAI,CAAC;QACJ,gBAAgB;QAChB,OAAO,SAAA;QACP,aAAa;QACb,IAAI,MAAA;QACJ,+DAA+D;QAC/D,OAAO,EAAE,KAAK;KACf,CAAC,CAAC;IACL,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,kBAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Send successful API response
|
|
5
|
+
* @author Gabe Abrams
|
|
6
|
+
* @param res express response
|
|
7
|
+
* @param body the body of the response to send to the client
|
|
8
|
+
*/
|
|
9
|
+
var handleSuccess = function (res, body) {
|
|
10
|
+
// Send a http 200 json response
|
|
11
|
+
res.json({
|
|
12
|
+
// Include the body as a parameter
|
|
13
|
+
body: body,
|
|
14
|
+
// Success = true flag so client can detect successful responses
|
|
15
|
+
success: true,
|
|
16
|
+
});
|
|
17
|
+
return undefined;
|
|
18
|
+
};
|
|
19
|
+
exports.default = handleSuccess;
|
|
20
|
+
//# sourceMappingURL=handleSuccess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleSuccess.js","sourceRoot":"","sources":["../../src/helpers/handleSuccess.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,IAAM,aAAa,GAAG,UAAC,GAAQ,EAAE,IAAS;IACxC,gCAAgC;IAChC,GAAG,CAAC,IAAI,CAAC;QACP,kCAAkC;QAClC,IAAI,MAAA;QACJ,gEAAgE;QAChE,OAAO,EAAE,IAAI;KACd,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,kBAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Collection as MangoCollection } from 'dce-mango';
|
|
2
|
+
/**
|
|
3
|
+
* Initialize a cross-server credential collection given the dce-mango Collection class
|
|
4
|
+
* @author Gabe Abrams
|
|
5
|
+
* @param Collection the Collection class from dce-mango
|
|
6
|
+
* @returns initialized logCollection
|
|
7
|
+
*/
|
|
8
|
+
declare const initCrossServerCredentialCollection: (Collection: typeof MangoCollection) => MangoCollection<{
|
|
9
|
+
[k: string]: any;
|
|
10
|
+
}>;
|
|
11
|
+
export default initCrossServerCredentialCollection;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Initialize a cross-server credential collection given the dce-mango Collection class
|
|
5
|
+
* @author Gabe Abrams
|
|
6
|
+
* @param Collection the Collection class from dce-mango
|
|
7
|
+
* @returns initialized logCollection
|
|
8
|
+
*/
|
|
9
|
+
var initCrossServerCredentialCollection = function (Collection) {
|
|
10
|
+
return new Collection('CrossServerCredential', {
|
|
11
|
+
uniqueIndexKey: 'key',
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
exports.default = initCrossServerCredentialCollection;
|
|
15
|
+
//# sourceMappingURL=initCrossServerCredentialCollection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initCrossServerCredentialCollection.js","sourceRoot":"","sources":["../../src/helpers/initCrossServerCredentialCollection.ts"],"names":[],"mappings":";;AAGA;;;;;GAKG;AACH,IAAM,mCAAmC,GAAG,UAAC,UAAkC;IAC7E,OAAO,IAAI,UAAU,CACnB,uBAAuB,EACvB;QACE,cAAc,EAAE,KAAK;KACtB,CACF,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Collection as MangoCollection } from 'dce-mango';
|
|
2
|
+
/**
|
|
3
|
+
* Initialize a log collection given the dce-mango Collection class
|
|
4
|
+
* @author Gabe Abrams
|
|
5
|
+
* @param Collection the Collection class from dce-mango
|
|
6
|
+
* @returns initialized logCollection
|
|
7
|
+
*/
|
|
8
|
+
declare const initLogCollection: (Collection: typeof MangoCollection) => MangoCollection<{
|
|
9
|
+
[k: string]: any;
|
|
10
|
+
}>;
|
|
11
|
+
export default initLogCollection;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Initialize a log collection given the dce-mango Collection class
|
|
5
|
+
* @author Gabe Abrams
|
|
6
|
+
* @param Collection the Collection class from dce-mango
|
|
7
|
+
* @returns initialized logCollection
|
|
8
|
+
*/
|
|
9
|
+
var initLogCollection = function (Collection) {
|
|
10
|
+
return new Collection('Log', {
|
|
11
|
+
uniqueIndexKey: 'id',
|
|
12
|
+
indexKeys: [
|
|
13
|
+
'courseId',
|
|
14
|
+
'context',
|
|
15
|
+
'subcontext',
|
|
16
|
+
'tags',
|
|
17
|
+
'year',
|
|
18
|
+
'month',
|
|
19
|
+
'day',
|
|
20
|
+
'hour',
|
|
21
|
+
'type',
|
|
22
|
+
],
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
exports.default = initLogCollection;
|
|
26
|
+
//# sourceMappingURL=initLogCollection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initLogCollection.js","sourceRoot":"","sources":["../../src/helpers/initLogCollection.ts"],"names":[],"mappings":";;AAIA;;;;;GAKG;AACH,IAAM,iBAAiB,GAAG,UAAC,UAAkC;IAC3D,OAAO,IAAI,UAAU,CACnB,KAAK,EACL;QACE,cAAc,EAAE,IAAI;QACpB,SAAS,EAAE;YACT,UAAU;YACV,SAAS;YACT,YAAY;YACZ,MAAM;YACN,MAAM;YACN,OAAO;YACP,KAAK;YACL,MAAM;YACN,MAAM;SACP;KACF,CACF,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import { Collection } from 'dce-mango';
|
|
3
|
+
/**
|
|
4
|
+
* Get log collection
|
|
5
|
+
* @author Gabe Abrams
|
|
6
|
+
* @returns log collection if one was included during launch or null if we don't
|
|
7
|
+
* have a log collection (yet)
|
|
8
|
+
*/
|
|
9
|
+
export declare const internalGetLogCollection: () => any;
|
|
10
|
+
/**
|
|
11
|
+
* Get cross-server credential collection
|
|
12
|
+
* @author Gabe Abrams
|
|
13
|
+
* @return cross-server credential collection if one was included during launch or null
|
|
14
|
+
* if we don't have a cross-server credential collection (yet)
|
|
15
|
+
*/
|
|
16
|
+
export declare const internalGetCrossServerCredentialCollection: () => any;
|
|
17
|
+
/**
|
|
18
|
+
* Prepare dce-reactkit to run on the server
|
|
19
|
+
* @author Gabe Abrams
|
|
20
|
+
* @param opts object containing all arguments
|
|
21
|
+
* @param opts.app express app from inside of the postprocessor function that
|
|
22
|
+
* we will add routes to
|
|
23
|
+
* @param opts.getLaunchInfo CACCL LTI's get launch info function
|
|
24
|
+
* @param [opts.logCollection] mongo collection from dce-mango to use for
|
|
25
|
+
* storing logs. If none is included, logs are written to the console
|
|
26
|
+
* @param [opts.logReviewAdmins=all] info on which admins can review
|
|
27
|
+
* logs from the client. If not included, all Canvas admins are allowed to
|
|
28
|
+
* review logs. If null, no Canvas admins are allowed to review logs.
|
|
29
|
+
* If an array of Canvas userIds (numbers), only Canvas admins with those
|
|
30
|
+
* userIds are allowed to review logs. If a dce-mango collection, only
|
|
31
|
+
* Canvas admins with entries in that collection ({ userId, ...}) are allowed
|
|
32
|
+
* to review logs
|
|
33
|
+
* @param [opts.crossServerCredentialCollection] mongo collection from dce-mango to use for
|
|
34
|
+
* storing cross-server credentials. If none is included, cross-server credentials
|
|
35
|
+
* are not supported
|
|
36
|
+
*/
|
|
37
|
+
declare const initServer: (opts: {
|
|
38
|
+
app: express.Application;
|
|
39
|
+
logReviewAdmins?: (number[] | Collection<any>);
|
|
40
|
+
logCollection?: Collection<any>;
|
|
41
|
+
crossServerCredentialCollection?: Collection<any>;
|
|
42
|
+
}) => void;
|
|
43
|
+
export default initServer;
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
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);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
exports.internalGetCrossServerCredentialCollection = exports.internalGetLogCollection = void 0;
|
|
54
|
+
// Import dce-reactkit
|
|
55
|
+
var dce_reactkit_1 = require("dce-reactkit");
|
|
56
|
+
// Import internal constants of dce-reactkit
|
|
57
|
+
var LOG_REVIEW_ROUTE_PATH_PREFIX_1 = __importDefault(require("dce-reactkit/src/constants/LOG_REVIEW_ROUTE_PATH_PREFIX"));
|
|
58
|
+
var LOG_ROUTE_PATH_1 = __importDefault(require("dce-reactkit/src/constants/LOG_ROUTE_PATH"));
|
|
59
|
+
var LOG_REVIEW_STATUS_ROUTE_1 = __importDefault(require("dce-reactkit/src/constants/LOG_REVIEW_STATUS_ROUTE"));
|
|
60
|
+
// Import shared helpers
|
|
61
|
+
var genRouteHandler_1 = __importDefault(require("./genRouteHandler"));
|
|
62
|
+
// Import shared types
|
|
63
|
+
var ExpressKitErrorCode_1 = __importDefault(require("../types/ExpressKitErrorCode"));
|
|
64
|
+
// Stored copy of dce-mango log collection
|
|
65
|
+
var _logCollection;
|
|
66
|
+
// Stored copy of dce-mango cross-server credential collection
|
|
67
|
+
var _crossServerCredentialCollection;
|
|
68
|
+
/*------------------------------------------------------------------------*/
|
|
69
|
+
/* Helpers */
|
|
70
|
+
/*------------------------------------------------------------------------*/
|
|
71
|
+
/**
|
|
72
|
+
* Get log collection
|
|
73
|
+
* @author Gabe Abrams
|
|
74
|
+
* @returns log collection if one was included during launch or null if we don't
|
|
75
|
+
* have a log collection (yet)
|
|
76
|
+
*/
|
|
77
|
+
var internalGetLogCollection = function () {
|
|
78
|
+
return _logCollection !== null && _logCollection !== void 0 ? _logCollection : null;
|
|
79
|
+
};
|
|
80
|
+
exports.internalGetLogCollection = internalGetLogCollection;
|
|
81
|
+
/**
|
|
82
|
+
* Get cross-server credential collection
|
|
83
|
+
* @author Gabe Abrams
|
|
84
|
+
* @return cross-server credential collection if one was included during launch or null
|
|
85
|
+
* if we don't have a cross-server credential collection (yet)
|
|
86
|
+
*/
|
|
87
|
+
var internalGetCrossServerCredentialCollection = function () {
|
|
88
|
+
return _crossServerCredentialCollection !== null && _crossServerCredentialCollection !== void 0 ? _crossServerCredentialCollection : null;
|
|
89
|
+
};
|
|
90
|
+
exports.internalGetCrossServerCredentialCollection = internalGetCrossServerCredentialCollection;
|
|
91
|
+
/*------------------------------------------------------------------------*/
|
|
92
|
+
/* Main */
|
|
93
|
+
/*------------------------------------------------------------------------*/
|
|
94
|
+
/**
|
|
95
|
+
* Prepare dce-reactkit to run on the server
|
|
96
|
+
* @author Gabe Abrams
|
|
97
|
+
* @param opts object containing all arguments
|
|
98
|
+
* @param opts.app express app from inside of the postprocessor function that
|
|
99
|
+
* we will add routes to
|
|
100
|
+
* @param opts.getLaunchInfo CACCL LTI's get launch info function
|
|
101
|
+
* @param [opts.logCollection] mongo collection from dce-mango to use for
|
|
102
|
+
* storing logs. If none is included, logs are written to the console
|
|
103
|
+
* @param [opts.logReviewAdmins=all] info on which admins can review
|
|
104
|
+
* logs from the client. If not included, all Canvas admins are allowed to
|
|
105
|
+
* review logs. If null, no Canvas admins are allowed to review logs.
|
|
106
|
+
* If an array of Canvas userIds (numbers), only Canvas admins with those
|
|
107
|
+
* userIds are allowed to review logs. If a dce-mango collection, only
|
|
108
|
+
* Canvas admins with entries in that collection ({ userId, ...}) are allowed
|
|
109
|
+
* to review logs
|
|
110
|
+
* @param [opts.crossServerCredentialCollection] mongo collection from dce-mango to use for
|
|
111
|
+
* storing cross-server credentials. If none is included, cross-server credentials
|
|
112
|
+
* are not supported
|
|
113
|
+
*/
|
|
114
|
+
var initServer = function (opts) {
|
|
115
|
+
_logCollection = opts.logCollection;
|
|
116
|
+
_crossServerCredentialCollection = opts.crossServerCredentialCollection;
|
|
117
|
+
/*----------------------------------------*/
|
|
118
|
+
/* Logging */
|
|
119
|
+
/*----------------------------------------*/
|
|
120
|
+
/**
|
|
121
|
+
* Log an event
|
|
122
|
+
* @author Gabe Abrams
|
|
123
|
+
* @param {string} context Context of the event (each app determines how to
|
|
124
|
+
* organize its contexts)
|
|
125
|
+
* @param {string} subcontext Subcontext of the event (each app determines
|
|
126
|
+
* how to organize its subcontexts)
|
|
127
|
+
* @param {string} tags stringified list of tags that apply to this action
|
|
128
|
+
* (each app determines tag usage)
|
|
129
|
+
* @param {string} metadata stringified object containing optional custom metadata
|
|
130
|
+
* @param {string} level log level
|
|
131
|
+
* @param {string} [errorMessage] error message if type is an error
|
|
132
|
+
* @param {string} [errorCode] error code if type is an error
|
|
133
|
+
* @param {string} [errorStack] error stack if type is an error
|
|
134
|
+
* @param {string} [target] Target of the action (each app determines the list
|
|
135
|
+
* of targets) These are usually buttons, panels, elements, etc.
|
|
136
|
+
* @param {LogAction} [action] the type of action performed on the target
|
|
137
|
+
* @returns {Log}
|
|
138
|
+
*/
|
|
139
|
+
opts.app.post(LOG_ROUTE_PATH_1.default, (0, genRouteHandler_1.default)({
|
|
140
|
+
paramTypes: {
|
|
141
|
+
context: dce_reactkit_1.ParamType.String,
|
|
142
|
+
subcontext: dce_reactkit_1.ParamType.String,
|
|
143
|
+
tags: dce_reactkit_1.ParamType.JSON,
|
|
144
|
+
level: dce_reactkit_1.ParamType.String,
|
|
145
|
+
metadata: dce_reactkit_1.ParamType.JSON,
|
|
146
|
+
errorMessage: dce_reactkit_1.ParamType.StringOptional,
|
|
147
|
+
errorCode: dce_reactkit_1.ParamType.StringOptional,
|
|
148
|
+
errorStack: dce_reactkit_1.ParamType.StringOptional,
|
|
149
|
+
target: dce_reactkit_1.ParamType.StringOptional,
|
|
150
|
+
action: dce_reactkit_1.ParamType.StringOptional,
|
|
151
|
+
},
|
|
152
|
+
handler: function (_a) {
|
|
153
|
+
var params = _a.params, logServerEvent = _a.logServerEvent;
|
|
154
|
+
// Create log info
|
|
155
|
+
var logInfo = ((params.errorMessage || params.errorCode || params.errorStack)
|
|
156
|
+
// Error
|
|
157
|
+
? {
|
|
158
|
+
context: params.context,
|
|
159
|
+
subcontext: params.subcontext,
|
|
160
|
+
tags: params.tags,
|
|
161
|
+
level: params.level,
|
|
162
|
+
metadata: params.metadata,
|
|
163
|
+
error: {
|
|
164
|
+
message: params.errorMessage,
|
|
165
|
+
code: params.errorCode,
|
|
166
|
+
stack: params.errorStack,
|
|
167
|
+
},
|
|
168
|
+
}
|
|
169
|
+
// Action
|
|
170
|
+
: {
|
|
171
|
+
context: params.context,
|
|
172
|
+
subcontext: params.subcontext,
|
|
173
|
+
tags: params.tags,
|
|
174
|
+
level: params.level,
|
|
175
|
+
metadata: params.metadata,
|
|
176
|
+
target: params.target,
|
|
177
|
+
action: params.action,
|
|
178
|
+
});
|
|
179
|
+
// Add hidden boolean to change source to "client"
|
|
180
|
+
var logInfoForcedFromClient = __assign(__assign({}, logInfo), { overrideAsClientEvent: true });
|
|
181
|
+
// Write the log
|
|
182
|
+
var log = logServerEvent(logInfoForcedFromClient);
|
|
183
|
+
// Return
|
|
184
|
+
return log;
|
|
185
|
+
},
|
|
186
|
+
}));
|
|
187
|
+
/*----------------------------------------*/
|
|
188
|
+
/* Log Reviewer */
|
|
189
|
+
/*----------------------------------------*/
|
|
190
|
+
/**
|
|
191
|
+
* Check if a given user is allowed to review logs
|
|
192
|
+
* @author Gabe Abrams
|
|
193
|
+
* @param userId the id of the user
|
|
194
|
+
* @param isAdmin if true, the user is an admin
|
|
195
|
+
* @returns true if the user can review logs
|
|
196
|
+
*/
|
|
197
|
+
var canReviewLogs = function (userId, isAdmin) { return __awaiter(void 0, void 0, void 0, function () {
|
|
198
|
+
var matches, err_1;
|
|
199
|
+
return __generator(this, function (_a) {
|
|
200
|
+
switch (_a.label) {
|
|
201
|
+
case 0:
|
|
202
|
+
// Immediately deny access if user is not an admin
|
|
203
|
+
if (!isAdmin) {
|
|
204
|
+
return [2 /*return*/, false];
|
|
205
|
+
}
|
|
206
|
+
// If all admins are allowed, we're done
|
|
207
|
+
if (!opts.logReviewAdmins) {
|
|
208
|
+
return [2 /*return*/, true];
|
|
209
|
+
}
|
|
210
|
+
_a.label = 1;
|
|
211
|
+
case 1:
|
|
212
|
+
_a.trys.push([1, 3, , 4]);
|
|
213
|
+
// Array of userIds
|
|
214
|
+
if (Array.isArray(opts.logReviewAdmins)) {
|
|
215
|
+
return [2 /*return*/, opts.logReviewAdmins.some(function (allowedId) {
|
|
216
|
+
return (userId === allowedId);
|
|
217
|
+
})];
|
|
218
|
+
}
|
|
219
|
+
return [4 /*yield*/, opts.logReviewAdmins.find({ userId: userId })];
|
|
220
|
+
case 2:
|
|
221
|
+
matches = _a.sent();
|
|
222
|
+
// Make sure at least one entry matches
|
|
223
|
+
return [2 /*return*/, matches.length > 0];
|
|
224
|
+
case 3:
|
|
225
|
+
err_1 = _a.sent();
|
|
226
|
+
// If an error occurred, simply return false
|
|
227
|
+
return [2 /*return*/, false];
|
|
228
|
+
case 4: return [2 /*return*/];
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
}); };
|
|
232
|
+
/**
|
|
233
|
+
* Check if the current user has access to logs
|
|
234
|
+
* @author Gabe Abrams
|
|
235
|
+
* @returns {boolean} true if user has access
|
|
236
|
+
*/
|
|
237
|
+
opts.app.get(LOG_REVIEW_STATUS_ROUTE_1.default, (0, genRouteHandler_1.default)({
|
|
238
|
+
handler: function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
239
|
+
var userId, isAdmin, canReview;
|
|
240
|
+
var params = _b.params;
|
|
241
|
+
return __generator(this, function (_c) {
|
|
242
|
+
switch (_c.label) {
|
|
243
|
+
case 0:
|
|
244
|
+
userId = params.userId, isAdmin = params.isAdmin;
|
|
245
|
+
return [4 /*yield*/, canReviewLogs(userId, isAdmin)];
|
|
246
|
+
case 1:
|
|
247
|
+
canReview = _c.sent();
|
|
248
|
+
return [2 /*return*/, canReview];
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
}); },
|
|
252
|
+
}));
|
|
253
|
+
/**
|
|
254
|
+
* Get all logs for a certain month
|
|
255
|
+
* @author Gabe Abrams
|
|
256
|
+
* @param {number} year the year to query (e.g. 2022)
|
|
257
|
+
* @param {number} month the month to query (e.g. 1 = January)
|
|
258
|
+
* @returns {Log[]} list of logs from the given month
|
|
259
|
+
*/
|
|
260
|
+
opts.app.get("".concat(LOG_REVIEW_ROUTE_PATH_PREFIX_1.default, "/years/:year/months/:month"), (0, genRouteHandler_1.default)({
|
|
261
|
+
paramTypes: {
|
|
262
|
+
year: dce_reactkit_1.ParamType.Int,
|
|
263
|
+
month: dce_reactkit_1.ParamType.Int,
|
|
264
|
+
pageNumber: dce_reactkit_1.ParamType.Int,
|
|
265
|
+
},
|
|
266
|
+
handler: function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
267
|
+
var year, month, pageNumber, userId, isAdmin, canReview, response;
|
|
268
|
+
var params = _b.params;
|
|
269
|
+
return __generator(this, function (_c) {
|
|
270
|
+
switch (_c.label) {
|
|
271
|
+
case 0:
|
|
272
|
+
year = params.year, month = params.month, pageNumber = params.pageNumber, userId = params.userId, isAdmin = params.isAdmin;
|
|
273
|
+
return [4 /*yield*/, canReviewLogs(userId, isAdmin)];
|
|
274
|
+
case 1:
|
|
275
|
+
canReview = _c.sent();
|
|
276
|
+
if (!canReview) {
|
|
277
|
+
throw new dce_reactkit_1.ErrorWithCode('You cannot access this resource because you do not have the appropriate permissions.', ExpressKitErrorCode_1.default.NotAllowedToReviewLogs);
|
|
278
|
+
}
|
|
279
|
+
return [4 /*yield*/, _logCollection.findPaged({
|
|
280
|
+
query: {
|
|
281
|
+
year: year,
|
|
282
|
+
month: month,
|
|
283
|
+
},
|
|
284
|
+
perPage: 1000,
|
|
285
|
+
pageNumber: pageNumber,
|
|
286
|
+
})];
|
|
287
|
+
case 2:
|
|
288
|
+
response = _c.sent();
|
|
289
|
+
// Return response
|
|
290
|
+
return [2 /*return*/, response];
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
}); },
|
|
294
|
+
}));
|
|
295
|
+
};
|
|
296
|
+
exports.default = initServer;
|
|
297
|
+
//# sourceMappingURL=initServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initServer.js","sourceRoot":"","sources":["../../src/helpers/initServer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,sBAAsB;AACtB,6CAIsB;AAEtB,4CAA4C;AAC5C,yHAAmG;AACn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AAK,EAAE,wBAAS,CAAC,GAAG;YACpB,UAAU,EAAE,wBAAS,CAAC,GAAG;SAC1B;QACD,OAAO,EAAE,iEAAO,EAAU;;gBAAR,MAAM,YAAA;;;;wBAGpB,IAAI,GAKF,MAAM,KALJ,EACJ,KAAK,GAIH,MAAM,MAJH,EACL,UAAU,GAGR,MAAM,WAHE,EACV,MAAM,GAEJ,MAAM,OAFF,EACN,OAAO,GACL,MAAM,QADD,CACE;wBAGO,qBAAM,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,EAAA;;wBAAhD,SAAS,GAAG,SAAoC;wBACtD,IAAI,CAAC,SAAS,EAAE,CAAC;4BACf,MAAM,IAAI,4BAAa,CACrB,sFAAsF,EACtF,6BAAmB,CAAC,sBAAsB,CAC3C,CAAC;wBACJ,CAAC;wBAGgB,qBAAM,cAAc,CAAC,SAAS,CAAC;gCAC9C,KAAK,EAAE;oCACL,IAAI,MAAA;oCACJ,KAAK,OAAA;iCACN;gCACD,OAAO,EAAE,IAAI;gCACb,UAAU,YAAA;6BACX,CAAC,EAAA;;wBAPI,QAAQ,GAAG,SAOf;wBAEF,kBAAkB;wBAClB,sBAAO,QAAQ,EAAC;;;aACjB;KACF,CAAC,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Perform a rudimentary parsing of the user's browser agent string
|
|
3
|
+
* @author Gabe Abrams
|
|
4
|
+
* @param userAgent the user's browser agent
|
|
5
|
+
* @returns user info
|
|
6
|
+
*/
|
|
7
|
+
declare const parseUserAgent: (userAgent: string) => {
|
|
8
|
+
browser: {
|
|
9
|
+
name: string;
|
|
10
|
+
version: string;
|
|
11
|
+
};
|
|
12
|
+
device: {
|
|
13
|
+
isMobile: boolean;
|
|
14
|
+
os: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export default parseUserAgent;
|