dce-reactkit 3.12.1-beta-cross-server.2 → 3.12.1-beta-cross-server.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.
- package/dist/cjs/index.js +8028 -190
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/helpers/dataSigner.d.ts +13 -11
- package/dist/cjs/types/helpers/visitEndpointOnAnotherServer/index.d.ts +0 -6
- package/dist/cjs/types/types/ReactKitErrorCode.d.ts +13 -11
- package/dist/esm/index.js +8027 -189
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/helpers/dataSigner.d.ts +13 -11
- package/dist/esm/types/helpers/visitEndpointOnAnotherServer/index.d.ts +0 -6
- package/dist/esm/types/types/ReactKitErrorCode.d.ts +13 -11
- package/dist/index.d.ts +13 -17
- package/genEncodedSecret.ts +67 -11
- package/package.json +3 -2
- package/rollup.config.js +2 -0
- package/src/helpers/dataSigner.ts +221 -113
- package/src/helpers/genRouteHandler.ts +27 -24
- package/src/helpers/visitEndpointOnAnotherServer/index.ts +84 -26
- package/src/types/ReactKitErrorCode.tsx +13 -11
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Sign
|
|
2
|
+
* Sign a request and get the new request params
|
|
3
3
|
* @author Gabe Abrams
|
|
4
4
|
* @param opts object containing all arguments
|
|
5
5
|
* @param opts.method the method to sign
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
* @param opts.params the data in the body to sign
|
|
8
8
|
* @param opts.key the reactkit key to sign with
|
|
9
9
|
* @param opts.secret the reactkit secret to sign with
|
|
10
|
-
* @return the
|
|
10
|
+
* @return augmented params for the request, including a signature, timestamp, and key
|
|
11
11
|
*/
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const signRequest: (opts: {
|
|
13
13
|
method: string;
|
|
14
14
|
path: string;
|
|
15
15
|
params: {
|
|
@@ -17,22 +17,24 @@ export declare const createSignedPack: (opts: {
|
|
|
17
17
|
};
|
|
18
18
|
key: string;
|
|
19
19
|
secret: string;
|
|
20
|
-
}) =>
|
|
20
|
+
}) => Promise<{
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
}>;
|
|
21
23
|
/**
|
|
22
|
-
*
|
|
24
|
+
* Validate a signed request. Throws an error if invalid
|
|
23
25
|
* @author Gabe Abrams
|
|
24
26
|
* @param opts object containing all arguments
|
|
25
27
|
* @param opts.method the method of the data validate
|
|
26
28
|
* @param opts.path the http request path to validate
|
|
27
29
|
* @param opts.scope the name of the scope to validate
|
|
28
|
-
* @param opts.
|
|
30
|
+
* @param opts.params the request data to validate
|
|
29
31
|
* @returns parsed and validated params
|
|
30
32
|
*/
|
|
31
|
-
export declare const
|
|
33
|
+
export declare const validateSignedRequest: (opts: {
|
|
32
34
|
method: string;
|
|
33
35
|
path: string;
|
|
34
36
|
scope: string;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}>;
|
|
37
|
+
params: {
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
};
|
|
40
|
+
}) => Promise<void>;
|
|
@@ -5,10 +5,6 @@
|
|
|
5
5
|
* @param opts.method the method of the endpoint
|
|
6
6
|
* @param opts.path the path of the other server's endpoint
|
|
7
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
8
|
* @param [opts.params={}] query/body parameters to include
|
|
13
9
|
* @param [opts.responseType=JSON] the response type from the other server
|
|
14
10
|
*/
|
|
@@ -16,8 +12,6 @@ declare const visitEndpointOnAnotherServer: (opts: {
|
|
|
16
12
|
method: 'GET' | 'POST' | 'DELETE' | 'PUT';
|
|
17
13
|
path: string;
|
|
18
14
|
host: string;
|
|
19
|
-
key?: string | undefined;
|
|
20
|
-
secret?: string | undefined;
|
|
21
15
|
params?: {
|
|
22
16
|
[x: string]: any;
|
|
23
17
|
} | undefined;
|
|
@@ -21,17 +21,19 @@ declare enum ReactKitErrorCode {
|
|
|
21
21
|
NotConnected = "DRK14",
|
|
22
22
|
SelfSigned = "DRK15",
|
|
23
23
|
ResponseParseError = "DRK16",
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
PackInvalidSignature = "DRK25",
|
|
32
|
-
PackInvalidBody = "DRK26",
|
|
24
|
+
SignedRequestUnparseable = "DRK28",
|
|
25
|
+
SignedRequestInvalidCollection = "DRK21",
|
|
26
|
+
SignedRequestInvalidCredential = "DRK23",
|
|
27
|
+
SignedRequestInvalidScope = "DRK22",
|
|
28
|
+
SignedRequestInvalidTimestamp = "DRK24",
|
|
29
|
+
SignedRequestInvalidSignature = "DRK25",
|
|
30
|
+
SignedRequestInvalidBody = "DRK26",
|
|
33
31
|
CrossServerNoCredentialsToSignWith = "DRK27",
|
|
34
|
-
|
|
35
|
-
CrossServerNoCredentialEncodingSalt = "DRK30"
|
|
32
|
+
CrossServerMissingSignedRequestInfo = "DRK29",
|
|
33
|
+
CrossServerNoCredentialEncodingSalt = "DRK30",
|
|
34
|
+
NoOauthLib = "DRK31",
|
|
35
|
+
NoCryptoLib = "DRK32",
|
|
36
|
+
InvalidCrossServerCredentialsFormat = "DRK33",
|
|
37
|
+
UnknownCrossServerError = "DRK34"
|
|
36
38
|
}
|
|
37
39
|
export default ReactKitErrorCode;
|