@xube/kit-destination 0.0.11 → 0.0.13

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/confirm.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ConfirmationRequest } from "./generated";
2
2
  import { XubeLog } from "@xube/kit-log";
3
3
  import { XubeResponse } from "@xube/kit-request";
4
- export declare const isConfirmation: (headers: Record<string, any>, body: Record<string, any>) => boolean;
4
+ export declare const isConfirmation: (headers: Record<string, any>, body: Record<string, any>, log?: XubeLog) => boolean;
5
5
  export declare const confirmDestination: (confirmationRequest: ConfirmationRequest, log?: XubeLog) => Promise<XubeResponse<boolean>>;
package/dist/confirm.js CHANGED
@@ -5,11 +5,17 @@ const generated_1 = require("./generated");
5
5
  const kit_constants_1 = require("@xube/kit-constants");
6
6
  const kit_log_1 = require("@xube/kit-log");
7
7
  const kit_request_1 = require("@xube/kit-request");
8
- const isConfirmation = (headers, body) => (0, generated_1.isDestinationHeaders)(headers) &&
9
- headers["x-amz-rules-engine-message-type"] === "DestinationConfirmation" &&
10
- (0, generated_1.isConfirmationRequest)(body);
8
+ const isConfirmation = (headers, body, log = kit_log_1.XubeLog.getInstance()) => {
9
+ log.info("Checking if confirmation request");
10
+ log.info(JSON.stringify(headers));
11
+ log.info(JSON.stringify(body));
12
+ return ((0, generated_1.isDestinationHeaders)(headers) &&
13
+ headers["x-amz-rules-engine-message-type"] === "DestinationConfirmation" &&
14
+ (0, generated_1.isConfirmationRequest)(body));
15
+ };
11
16
  exports.isConfirmation = isConfirmation;
12
17
  const confirmDestination = async (confirmationRequest, log = kit_log_1.XubeLog.getInstance()) => {
18
+ log.info("Attempting to confirm destination");
13
19
  const response = await fetch(confirmationRequest.enableUrl, {
14
20
  method: "GET",
15
21
  headers: {
@@ -23,6 +29,9 @@ const confirmDestination = async (confirmationRequest, log = kit_log_1.XubeLog.g
23
29
  error: "Failed to confirm destination",
24
30
  });
25
31
  }
32
+ else {
33
+ log.info("Successfully confirmed destination");
34
+ }
26
35
  return new kit_request_1.XubeResponse({
27
36
  statusCode: kit_constants_1.StatusCode.OK,
28
37
  data: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xube/kit-destination",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -19,13 +19,13 @@
19
19
  "homepage": "https://github.com/XubeLtd/dev-kit#readme",
20
20
  "devDependencies": {
21
21
  "@types/node": "^20.4.7",
22
- "@xube/kit-build": "^0.0.11",
22
+ "@xube/kit-build": "^0.0.13",
23
23
  "ts-node": "^10.9.1",
24
24
  "typescript": "^5.1.6"
25
25
  },
26
26
  "dependencies": {
27
- "@xube/kit-generator": "^0.0.11",
28
- "@xube/kit-log": "^0.0.11",
29
- "@xube/kit-request": "^0.0.11"
27
+ "@xube/kit-generator": "^0.0.13",
28
+ "@xube/kit-log": "^0.0.13",
29
+ "@xube/kit-request": "^0.0.13"
30
30
  }
31
31
  }
package/src/confirm.ts CHANGED
@@ -9,16 +9,26 @@ import { XubeResponse } from "@xube/kit-request";
9
9
 
10
10
  export const isConfirmation = (
11
11
  headers: Record<string, any>,
12
- body: Record<string, any>
13
- ): boolean =>
14
- isDestinationHeaders(headers) &&
15
- headers["x-amz-rules-engine-message-type"] === "DestinationConfirmation" &&
16
- isConfirmationRequest(body);
12
+ body: Record<string, any>,
13
+ log: XubeLog = XubeLog.getInstance()
14
+ ): boolean => {
15
+ log.info("Checking if confirmation request");
16
+
17
+ log.info(JSON.stringify(headers));
18
+ log.info(JSON.stringify(body));
19
+
20
+ return (
21
+ isDestinationHeaders(headers) &&
22
+ headers["x-amz-rules-engine-message-type"] === "DestinationConfirmation" &&
23
+ isConfirmationRequest(body)
24
+ );
25
+ };
17
26
 
18
27
  export const confirmDestination = async (
19
28
  confirmationRequest: ConfirmationRequest,
20
29
  log: XubeLog = XubeLog.getInstance()
21
30
  ): Promise<XubeResponse<boolean>> => {
31
+ log.info("Attempting to confirm destination");
22
32
  const response = await fetch(confirmationRequest.enableUrl, {
23
33
  method: "GET",
24
34
  headers: {
@@ -32,6 +42,8 @@ export const confirmDestination = async (
32
42
  statusCode: StatusCode.BadRequest,
33
43
  error: "Failed to confirm destination",
34
44
  });
45
+ } else {
46
+ log.info("Successfully confirmed destination");
35
47
  }
36
48
  return new XubeResponse({
37
49
  statusCode: StatusCode.OK,