@socket.tech/dl-common 1.0.3-test.25 → 1.0.3-test.27

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,6 +1,6 @@
1
1
  import { TripReason } from "../models";
2
2
  import { StatusCodes } from "./enums";
3
- import { IntegrationTypes } from "@socket.tech/dl-core";
3
+ import { ChainSlug, IntegrationTypes } from "@socket.tech/dl-core";
4
4
  export type Speed = "safeLow" | "average" | "fast" | "fastest";
5
5
  export declare enum InboundStatus {
6
6
  NOT_TRIED = "NOT_TRIED",
@@ -116,3 +116,15 @@ export type MessageData = {
116
116
  executionParams: string;
117
117
  packedMessage: string;
118
118
  };
119
+ export type S3Config = {
120
+ chains: {
121
+ [chainSlug in ChainSlug]?: {
122
+ rpc: string;
123
+ blockNumber: number;
124
+ confirmations: number;
125
+ };
126
+ };
127
+ batcherSupportedChainSlugs: ChainSlug[];
128
+ watcherSupportedChainSlugs: ChainSlug[];
129
+ transmitterSupportedChainSlugs: ChainSlug[];
130
+ };
@@ -10,3 +10,4 @@ export * from "./signer";
10
10
  export * from "./ethersAwsKmsSigner";
11
11
  export * from "./secretManagerService";
12
12
  export * from "./eventGetter";
13
+ export * from "./s3Service";
@@ -26,3 +26,4 @@ __exportStar(require("./signer"), exports);
26
26
  __exportStar(require("./ethersAwsKmsSigner"), exports);
27
27
  __exportStar(require("./secretManagerService"), exports);
28
28
  __exportStar(require("./eventGetter"), exports);
29
+ __exportStar(require("./s3Service"), exports);
@@ -0,0 +1,2 @@
1
+ export declare const initS3Client: (region: string) => Promise<void>;
2
+ export declare const getFileFromS3: (bucket: string, filePath: string) => Promise<any>;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getFileFromS3 = exports.initS3Client = void 0;
4
+ const client_s3_1 = require("@aws-sdk/client-s3");
5
+ // Set your AWS credentials and region
6
+ let s3Client;
7
+ const initS3Client = async (region) => {
8
+ s3Client = new client_s3_1.S3Client({
9
+ region,
10
+ });
11
+ };
12
+ exports.initS3Client = initS3Client;
13
+ const getFileFromS3 = async (bucket, filePath) => {
14
+ var _a;
15
+ try {
16
+ // Create an S3 GET operation command
17
+ const getObjectCommand = new client_s3_1.GetObjectCommand({
18
+ Bucket: bucket,
19
+ Key: filePath,
20
+ });
21
+ // Execute the command and get the response
22
+ const s3Response = await s3Client.send(getObjectCommand);
23
+ let jsonStr = await ((_a = s3Response.Body) === null || _a === void 0 ? void 0 : _a.transformToString());
24
+ let response;
25
+ if (jsonStr)
26
+ response = JSON.parse(jsonStr);
27
+ return response;
28
+ }
29
+ catch (error) {
30
+ console.error("Error downloading file from S3:", error);
31
+ throw error;
32
+ }
33
+ };
34
+ exports.getFileFromS3 = getFileFromS3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socket.tech/dl-common",
3
- "version": "1.0.3-test.25",
3
+ "version": "1.0.3-test.27",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "description": "common utilities for socket data layer.",
@@ -44,7 +44,7 @@
44
44
  "@aws-sdk/client-sqs": "^3.421.0",
45
45
  "@aws-sdk/smithy-client": "^3.329.0",
46
46
  "@ethersproject/providers": "^5.7.2",
47
- "@socket.tech/dl-core": "2.4.13",
47
+ "@socket.tech/dl-core": "2.4.1-3.test-0",
48
48
  "@socket.tech/ll-common": "^0.0.19",
49
49
  "async-redis": "^2.0.0",
50
50
  "aws-kms-ethers-signer": "^0.1.3",
@@ -59,6 +59,7 @@
59
59
  "sequelize": "^6.21.6"
60
60
  },
61
61
  "devDependencies": {
62
+ "@aws-sdk/client-s3": "^3.456.0",
62
63
  "@babel/core": "^7.23.3",
63
64
  "@babel/preset-env": "^7.23.3",
64
65
  "@babel/preset-typescript": "^7.23.3",