dce-reactkit 3.12.1-beta-cross-server.2 → 3.12.3

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 (51) hide show
  1. package/.vscode/settings.json +3 -1
  2. package/README.md +0 -20
  3. package/dist/cjs/index.js +356 -406
  4. package/dist/cjs/index.js.map +1 -1
  5. package/dist/cjs/types/components/ItemPicker/index.d.ts +1 -0
  6. package/dist/cjs/types/components/Modal/ModalProps.d.ts +2 -0
  7. package/dist/cjs/types/components/TabBox.d.ts +1 -0
  8. package/dist/cjs/types/helpers/genRouteHandler.d.ts +10 -10
  9. package/dist/cjs/types/helpers/getWordCount.d.ts +10 -0
  10. package/dist/cjs/types/helpers/visitEndpointOnAnotherServer/index.d.ts +13 -15
  11. package/dist/cjs/types/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.d.ts +6 -0
  12. package/dist/cjs/types/index.d.ts +2 -3
  13. package/dist/cjs/types/server/initServer.d.ts +0 -11
  14. package/dist/cjs/types/types/ReactKitErrorCode.d.ts +1 -13
  15. package/dist/esm/index.js +357 -406
  16. package/dist/esm/index.js.map +1 -1
  17. package/dist/esm/types/components/ItemPicker/index.d.ts +1 -0
  18. package/dist/esm/types/components/Modal/ModalProps.d.ts +2 -0
  19. package/dist/esm/types/components/TabBox.d.ts +1 -0
  20. package/dist/esm/types/helpers/genRouteHandler.d.ts +10 -10
  21. package/dist/esm/types/helpers/getWordCount.d.ts +10 -0
  22. package/dist/esm/types/helpers/visitEndpointOnAnotherServer/index.d.ts +13 -15
  23. package/dist/esm/types/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.d.ts +6 -0
  24. package/dist/esm/types/index.d.ts +2 -3
  25. package/dist/esm/types/server/initServer.d.ts +0 -11
  26. package/dist/esm/types/types/ReactKitErrorCode.d.ts +1 -13
  27. package/dist/index.d.ts +39 -62
  28. package/package.json +2 -5
  29. package/src/components/IntelliTable.tsx +1 -1
  30. package/src/components/ItemPicker/NestableItemList.tsx +1 -0
  31. package/src/components/ItemPicker/index.tsx +96 -0
  32. package/src/components/Modal/ModalProps.ts +4 -0
  33. package/src/components/Modal/index.tsx +59 -20
  34. package/src/components/TabBox.tsx +27 -9
  35. package/src/helpers/genRouteHandler.ts +95 -55
  36. package/src/helpers/getWordCount.ts +26 -0
  37. package/src/helpers/visitEndpointOnAnotherServer/index.ts +41 -42
  38. package/src/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.ts +5 -3
  39. package/src/index.ts +2 -4
  40. package/src/server/initServer.ts +0 -18
  41. package/src/types/ReactKitErrorCode.tsx +1 -13
  42. package/dist/cjs/types/helpers/dataSigner.d.ts +0 -38
  43. package/dist/cjs/types/server/initCrossServerCredentialCollection.d.ts +0 -8
  44. package/dist/cjs/types/types/CrossServerCredential.d.ts +0 -11
  45. package/dist/esm/types/helpers/dataSigner.d.ts +0 -38
  46. package/dist/esm/types/server/initCrossServerCredentialCollection.d.ts +0 -8
  47. package/dist/esm/types/types/CrossServerCredential.d.ts +0 -11
  48. package/genEncodedSecret.ts +0 -28
  49. package/src/helpers/dataSigner.ts +0 -232
  50. package/src/server/initCrossServerCredentialCollection.ts +0 -16
  51. package/src/types/CrossServerCredential.ts +0 -16
@@ -14,6 +14,7 @@ type Props = {
14
14
  */
15
15
  onChanged: (updatedItems: PickableItem[]) => void;
16
16
  noBottomMargin?: boolean;
17
+ hideSelectAllOrNoneButtons?: boolean;
17
18
  };
18
19
  declare const ItemPicker: React.FC<Props>;
19
20
  export default ItemPicker;
@@ -38,5 +38,7 @@ type ModalProps = {
38
38
  confirmLabel?: string;
39
39
  confirmVariant?: Variant;
40
40
  onTopOfOtherModals?: boolean;
41
+ isLoading?: boolean;
42
+ isLoadingCancelable?: boolean;
41
43
  };
42
44
  export default ModalProps;
@@ -6,6 +6,7 @@ import React from 'react';
6
6
  type Props = {
7
7
  title: React.ReactNode;
8
8
  children: React.ReactNode;
9
+ topRightChildren?: React.ReactNode;
9
10
  noBottomMargin?: boolean;
10
11
  noBottomPadding?: boolean;
11
12
  };
@@ -7,15 +7,14 @@ import LogFunction from '../types/LogFunction';
7
7
  * @param opts.paramTypes map containing the types for each parameter that is
8
8
  * included in the request (map: param name => type)
9
9
  * @param opts.handler function that processes the request
10
- * @param [opts.crossServerScope] the scope associated with this endpoint.
11
- * If defined, this is a cross-server endpoint, which will never
12
- * have any launch data, will never check Canvas roles or launch status, and will
13
- * instead use scopes and reactkit credentials to sign and validate requests.
14
- * Never start the path with /api/ttm or /api/admin if the endpoint is a cross-server
15
- * endpoint because those roles will not be validated
16
- * @param [opts.skipSessionCheck=true if crossServerScope defined] if true, skip
17
- * the session check (allow users to not be logged in and launched via LTI).
18
- * If crossServerScope is defined, this is always true
10
+ * @param [opts.skipSessionCheck] if true, skip the session check (allow users
11
+ * to not be logged in and launched via LTI)
12
+ * @param [opts.allowedHosts] if included, only allow requests from these hosts
13
+ * (start a hostname with a "*" to only check the end of the hostname)
14
+ * you can include just one string instead of an array
15
+ * @param [opts.bannedHosts] if included, do not allow requests from these hosts
16
+ * (start a hostname with a "*" to only check the end of the hostname)
17
+ * you can include just one string instead of an array
19
18
  * @param [opts.unhandledErrorMessagePrefix] if included, when an error that
20
19
  * is not of type ErrorWithCode is thrown, the client will receive an error
21
20
  * where the error message is prefixed with this string. For example,
@@ -69,8 +68,9 @@ declare const genRouteHandler: (opts: {
69
68
  }) => void;
70
69
  logServerEvent: LogFunction;
71
70
  }) => any;
72
- crossServerScope?: string | undefined;
73
71
  skipSessionCheck?: boolean | undefined;
72
+ allowedHosts?: string | string[] | undefined;
73
+ bannedHosts?: string | string[] | undefined;
74
74
  unhandledErrorMessagePrefix?: string | undefined;
75
75
  }) => (req: any, res: any, next: () => void) => Promise<undefined>;
76
76
  export default genRouteHandler;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Get number of words in string
3
+ * @author Gardenia Liu
4
+ * @author Allison Zhang
5
+ * @author Gabe Abrams
6
+ * @param text the string to check
7
+ * @returns number of words in the string
8
+ */
9
+ declare const getWordCount: (text: string) => number;
10
+ export default getWordCount;
@@ -1,26 +1,24 @@
1
1
  /**
2
- * Visit an endpoint on another server
2
+ * Send a server-to-server request from this sever to another server that uses
3
+ * dce-reactkit [for server only]
3
4
  * @author Gabe Abrams
4
5
  * @param opts object containing all arguments
5
- * @param opts.method the method of the endpoint
6
- * @param opts.path the path of the other server's endpoint
7
- * @param opts.host the host of the other server
8
- * @param [opts.key=process.env.REACTKIT_CROSS_SERVER_CREDENTIAL_KEY] reactkit cross-server
9
- * credential key
10
- * @param [opts.secret=process.env.REACTKIT_CROSS_SERVER_CREDENTIAL_SECRET reactkit cross-server
11
- * credential secret
12
- * @param [opts.params={}] query/body parameters to include
13
- * @param [opts.responseType=JSON] the response type from the other server
6
+ * @param opts.host - the host of the other server
7
+ * @param opts.path - the path of the other server's endpoint
8
+ * @param [opts.method=GET] - the method of the endpoint
9
+ * @param [opts.params] - query/body parameters to include
10
+ * @param [opts.headers] - headers to include
11
+ * @returns response from server
14
12
  */
15
13
  declare const visitEndpointOnAnotherServer: (opts: {
16
- method: 'GET' | 'POST' | 'DELETE' | 'PUT';
17
- path: string;
18
14
  host: string;
19
- key?: string | undefined;
20
- secret?: string | undefined;
15
+ path: string;
16
+ method?: "GET" | "POST" | "DELETE" | "PUT" | undefined;
21
17
  params?: {
22
18
  [x: string]: any;
23
19
  } | undefined;
24
- responseType?: "Text" | "JSON" | undefined;
20
+ headers?: {
21
+ [x: string]: any;
22
+ } | undefined;
25
23
  }) => Promise<any>;
26
24
  export default visitEndpointOnAnotherServer;
@@ -6,6 +6,9 @@
6
6
  * @param [opts.host] host to send request to
7
7
  * @param [opts.method=GET] http method to use
8
8
  * @param [opts.params] body/data to include in the request
9
+ * @param [opts.headers] headers to include in the request
10
+ * @param [opts.sendCrossDomainCredentials=true if in development mode] if true,
11
+ * send cross-domain credentials even if not in dev mode
9
12
  * @param [opts.responseType=JSON] expected response type
10
13
  * @returns { body, status, headers } on success
11
14
  */
@@ -16,6 +19,9 @@ declare const sendServerToServerRequest: (opts: {
16
19
  params?: {
17
20
  [x: string]: any;
18
21
  } | undefined;
22
+ headers?: {
23
+ [x: string]: any;
24
+ } | undefined;
19
25
  responseType?: "Text" | "JSON" | undefined;
20
26
  }) => Promise<{
21
27
  body: any;
@@ -54,7 +54,6 @@ import onlyKeepLetters from './helpers/onlyKeepLetters';
54
54
  import parallelLimit from './helpers/parallelLimit';
55
55
  import logClientEvent, { setClientEventMetadataPopulator } from './helpers/logClientEvent';
56
56
  import initLogCollection from './server/initLogCollection';
57
- import initCrossServerCredentialCollection from './server/initCrossServerCredentialCollection';
58
57
  import getMonthName from './helpers/getMonthName';
59
58
  import genCSV from './helpers/genCSV';
60
59
  import canReviewLogs from './helpers/canReviewLogs';
@@ -80,6 +79,7 @@ import someAsync from './helpers/asyncArrayFunctions/someAsync';
80
79
  import capitalize from './helpers/capitalize';
81
80
  import shuffleArray from './helpers/shuffleArray';
82
81
  import visitEndpointOnAnotherServer from './helpers/visitEndpointOnAnotherServer';
82
+ import getWordCount from './helpers/getWordCount';
83
83
  import ModalButtonType from './types/ModalButtonType';
84
84
  import ModalSize from './types/ModalSize';
85
85
  import ModalType from './types/ModalType';
@@ -96,9 +96,8 @@ import LogMetadataType from './types/LogMetadataType';
96
96
  import LogFunction from './types/LogFunction';
97
97
  import IntelliTableColumn from './types/IntelliTableColumn';
98
98
  import DropdownItemType from './types/DropdownItemType';
99
- import CrossServerCredential from './types/CrossServerCredential';
100
99
  import PickableItem from './components/ItemPicker/types/PickableItem';
101
100
  import DBEntry from './components/DBEntryManagerPanel/types/DBEntry';
102
101
  import DBEntryField from './components/DBEntryManagerPanel/types/DBEntryField';
103
102
  import DBEntryFieldType from './components/DBEntryManagerPanel/types/DBEntryFieldType';
104
- export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, MultiSwitch, Dropdown, alert, prompt, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, idify, makeLinksClickable, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, combineClassNames, useForceRender, setClientEventMetadataPopulator, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, initCrossServerCredentialCollection, addDBEditorEndpoints, visitEndpointOnAnotherServer, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, IntelliTableColumn, DropdownItemType, CrossServerCredential, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
103
+ export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, MultiSwitch, Dropdown, alert, prompt, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, idify, makeLinksClickable, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, getWordCount, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, combineClassNames, useForceRender, setClientEventMetadataPopulator, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, addDBEditorEndpoints, visitEndpointOnAnotherServer, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, IntelliTableColumn, DropdownItemType, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
@@ -16,13 +16,6 @@ export declare const cacclGetLaunchInfo: GetLaunchInfoFunction;
16
16
  * have a log collection (yet)
17
17
  */
18
18
  export declare const internalGetLogCollection: () => any;
19
- /**
20
- * Get cross-server credential collection
21
- * @author Gabe Abrams
22
- * @return cross-server credential collection if one was included during launch or null
23
- * if we don't have a cross-server credential collection (yet)
24
- */
25
- export declare const internalGetCrossServerCredentialCollection: () => any;
26
19
  /**
27
20
  * Prepare dce-reactkit to run on the server
28
21
  * @author Gabe Abrams
@@ -39,15 +32,11 @@ export declare const internalGetCrossServerCredentialCollection: () => any;
39
32
  * userIds are allowed to review logs. If a dce-mango collection, only
40
33
  * Canvas admins with entries in that collection ({ userId, ...}) are allowed
41
34
  * to review logs
42
- * @param [opts.crossServerCredentialCollection] mongo collection from dce-mango to use for
43
- * storing cross-server credentials. If none is included, cross-server credentials
44
- * are not supported
45
35
  */
46
36
  declare const initServer: (opts: {
47
37
  app: any;
48
38
  getLaunchInfo: GetLaunchInfoFunction;
49
39
  logCollection?: any;
50
40
  logReviewAdmins?: (number[] | any);
51
- crossServerCredentialCollection?: any;
52
41
  }) => void;
53
42
  export default initServer;
@@ -20,18 +20,6 @@ declare enum ReactKitErrorCode {
20
20
  SessionExpiredMessageGottenBeforeReactKitReady = "DRK13",
21
21
  NotConnected = "DRK14",
22
22
  SelfSigned = "DRK15",
23
- ResponseParseError = "DRK16",
24
- PackUnparseable = "DRK28",
25
- PackInvalidMethod = "DRK19",
26
- PackInvalidPath = "DRK20",
27
- PackInvalidCollection = "DRK21",
28
- PackInvalidCredential = "DRK23",
29
- PackInvalidScope = "DRK22",
30
- PackInvalidTimestamp = "DRK24",
31
- PackInvalidSignature = "DRK25",
32
- PackInvalidBody = "DRK26",
33
- CrossServerNoCredentialsToSignWith = "DRK27",
34
- CrossServerNoPack = "DRK29",
35
- CrossServerNoCredentialEncodingSalt = "DRK30"
23
+ ResponseParseError = "DRK16"
36
24
  }
37
25
  export default ReactKitErrorCode;