dce-reactkit 3.11.4 → 3.12.1-beta-cross-server.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/.vscode/settings.json +1 -3
- package/README.md +20 -0
- package/dist/cjs/index.js +294 -162
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/helpers/dataSigner.d.ts +38 -0
- package/dist/cjs/types/helpers/genRouteHandler.d.ts +10 -10
- package/dist/cjs/types/helpers/visitEndpointOnAnotherServer/index.d.ts +15 -13
- package/dist/cjs/types/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.d.ts +0 -6
- package/dist/cjs/types/index.d.ts +3 -2
- package/dist/cjs/types/server/initCrossServerCredentialCollection.d.ts +8 -0
- package/dist/cjs/types/server/initServer.d.ts +11 -0
- package/dist/cjs/types/types/CrossServerCredential.d.ts +11 -0
- package/dist/cjs/types/types/ReactKitErrorCode.d.ts +13 -1
- package/dist/esm/index.js +293 -162
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/helpers/dataSigner.d.ts +38 -0
- package/dist/esm/types/helpers/genRouteHandler.d.ts +10 -10
- package/dist/esm/types/helpers/visitEndpointOnAnotherServer/index.d.ts +15 -13
- package/dist/esm/types/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.d.ts +0 -6
- package/dist/esm/types/index.d.ts +3 -2
- package/dist/esm/types/server/initCrossServerCredentialCollection.d.ts +8 -0
- package/dist/esm/types/server/initServer.d.ts +11 -0
- package/dist/esm/types/types/CrossServerCredential.d.ts +11 -0
- package/dist/esm/types/types/ReactKitErrorCode.d.ts +13 -1
- package/dist/index.d.ts +62 -35
- package/genEncodedSecret.ts +28 -0
- package/package.json +5 -2
- package/src/components/IntelliTable.tsx +1 -1
- package/src/components/ItemPicker/NestableItemList.tsx +0 -1
- package/src/helpers/dataSigner.ts +232 -0
- package/src/helpers/genRouteHandler.ts +55 -95
- package/src/helpers/visitEndpointOnAnotherServer/index.ts +42 -41
- package/src/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.ts +3 -5
- package/src/index.ts +4 -2
- package/src/server/initCrossServerCredentialCollection.ts +16 -0
- package/src/server/initServer.ts +18 -0
- package/src/types/CrossServerCredential.ts +16 -0
- package/src/types/ReactKitErrorCode.tsx +13 -1
- package/dist/cjs/types/helpers/getWordCount.d.ts +0 -10
- package/dist/esm/types/helpers/getWordCount.d.ts +0 -10
- package/src/helpers/getWordCount.ts +0 -26
package/src/server/initServer.ts
CHANGED
|
@@ -27,6 +27,9 @@ let _cacclGetLaunchInfo: GetLaunchInfoFunction;
|
|
|
27
27
|
// Stored copy of dce-mango log collection
|
|
28
28
|
let _logCollection: any;
|
|
29
29
|
|
|
30
|
+
// Stored copy of dce-mango cross-server credential collection
|
|
31
|
+
let _crossServerCredentialCollection: any;
|
|
32
|
+
|
|
30
33
|
/*------------------------------------------------------------------------*/
|
|
31
34
|
/* Helpers */
|
|
32
35
|
/*------------------------------------------------------------------------*/
|
|
@@ -58,6 +61,16 @@ export const internalGetLogCollection = () => {
|
|
|
58
61
|
return _logCollection ?? null;
|
|
59
62
|
};
|
|
60
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Get cross-server credential collection
|
|
66
|
+
* @author Gabe Abrams
|
|
67
|
+
* @return cross-server credential collection if one was included during launch or null
|
|
68
|
+
* if we don't have a cross-server credential collection (yet)
|
|
69
|
+
*/
|
|
70
|
+
export const internalGetCrossServerCredentialCollection = () => {
|
|
71
|
+
return _crossServerCredentialCollection ?? null;
|
|
72
|
+
};
|
|
73
|
+
|
|
61
74
|
/*------------------------------------------------------------------------*/
|
|
62
75
|
/* Main */
|
|
63
76
|
/*------------------------------------------------------------------------*/
|
|
@@ -78,6 +91,9 @@ export const internalGetLogCollection = () => {
|
|
|
78
91
|
* userIds are allowed to review logs. If a dce-mango collection, only
|
|
79
92
|
* Canvas admins with entries in that collection ({ userId, ...}) are allowed
|
|
80
93
|
* to review logs
|
|
94
|
+
* @param [opts.crossServerCredentialCollection] mongo collection from dce-mango to use for
|
|
95
|
+
* storing cross-server credentials. If none is included, cross-server credentials
|
|
96
|
+
* are not supported
|
|
81
97
|
*/
|
|
82
98
|
const initServer = (
|
|
83
99
|
opts: {
|
|
@@ -85,10 +101,12 @@ const initServer = (
|
|
|
85
101
|
getLaunchInfo: GetLaunchInfoFunction,
|
|
86
102
|
logCollection?: any,
|
|
87
103
|
logReviewAdmins?: (number[] | any),
|
|
104
|
+
crossServerCredentialCollection?: any,
|
|
88
105
|
},
|
|
89
106
|
) => {
|
|
90
107
|
_cacclGetLaunchInfo = opts.getLaunchInfo;
|
|
91
108
|
_logCollection = opts.logCollection;
|
|
109
|
+
_crossServerCredentialCollection = opts.crossServerCredentialCollection;
|
|
92
110
|
|
|
93
111
|
/*----------------------------------------*/
|
|
94
112
|
/* Logging */
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single cross-server credential
|
|
3
|
+
* @author Gabe Abrams
|
|
4
|
+
*/
|
|
5
|
+
type CrossServerCredential = {
|
|
6
|
+
// Description of the credential (human-readable)
|
|
7
|
+
description: string,
|
|
8
|
+
// The key of the credential
|
|
9
|
+
key: string,
|
|
10
|
+
// The encoded secret of the credential
|
|
11
|
+
encodedeSecret: string,
|
|
12
|
+
// The list of scopes for the credential
|
|
13
|
+
scopes: string[],
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default CrossServerCredential;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Highest error code =
|
|
1
|
+
// Highest error code = DRK30
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* List of error codes built into the react kit
|
|
@@ -25,6 +25,18 @@ enum ReactKitErrorCode {
|
|
|
25
25
|
NotConnected = 'DRK14',
|
|
26
26
|
SelfSigned = 'DRK15',
|
|
27
27
|
ResponseParseError = 'DRK16',
|
|
28
|
+
PackUnparseable = 'DRK28',
|
|
29
|
+
PackInvalidMethod = 'DRK19',
|
|
30
|
+
PackInvalidPath = 'DRK20',
|
|
31
|
+
PackInvalidCollection = 'DRK21',
|
|
32
|
+
PackInvalidCredential = 'DRK23',
|
|
33
|
+
PackInvalidScope = 'DRK22',
|
|
34
|
+
PackInvalidTimestamp = 'DRK24',
|
|
35
|
+
PackInvalidSignature = 'DRK25',
|
|
36
|
+
PackInvalidBody = 'DRK26',
|
|
37
|
+
CrossServerNoCredentialsToSignWith = 'DRK27',
|
|
38
|
+
CrossServerNoPack = 'DRK29',
|
|
39
|
+
CrossServerNoCredentialEncodingSalt = 'DRK30',
|
|
28
40
|
}
|
|
29
41
|
|
|
30
42
|
export default ReactKitErrorCode;
|
|
@@ -1,10 +0,0 @@
|
|
|
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,10 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
1
|
-
const punctuationRegex = /[!@#$%^&*(),.?\/;:'"\-\[\]]/g;
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Get number of words in string
|
|
5
|
-
* @author Gardenia Liu
|
|
6
|
-
* @author Allison Zhang
|
|
7
|
-
* @author Gabe Abrams
|
|
8
|
-
* @param text the string to check
|
|
9
|
-
* @returns number of words in the string
|
|
10
|
-
*/
|
|
11
|
-
const getWordCount = (text: string): number => {
|
|
12
|
-
const trimmedTextWithoutPunctuation = (
|
|
13
|
-
text
|
|
14
|
-
// Remove leading and trailing whitespace
|
|
15
|
-
.trim()
|
|
16
|
-
// Remove punctuation
|
|
17
|
-
.replace(punctuationRegex, '')
|
|
18
|
-
);
|
|
19
|
-
if (trimmedTextWithoutPunctuation.length === 0) {
|
|
20
|
-
return 0;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return trimmedTextWithoutPunctuation.split(/\s+/g).length;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export default getWordCount;
|