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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Sign data with a private reactkit key, package it into a signed data pack
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 signed data
10
+ * @return augmented params for the request, including a signature, timestamp, and key
11
11
  */
12
- export declare const createSignedPack: (opts: {
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
- }) => string;
20
+ }) => Promise<{
21
+ [key: string]: any;
22
+ }>;
21
23
  /**
22
- * Parse signed pack. Throws an error if invalid
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.signedPack the signed data pack to validate
30
+ * @param opts.params the request data to validate
29
31
  * @returns parsed and validated params
30
32
  */
31
- export declare const parseSignedPack: (opts: {
33
+ export declare const validateSignedRequest: (opts: {
32
34
  method: string;
33
35
  path: string;
34
36
  scope: string;
35
- signedPack: string;
36
- }) => Promise<{
37
- [key: string]: any;
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
- 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",
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
- CrossServerNoPack = "DRK29",
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;