@socket.tech/dl-common 1.0.3-test.1 → 1.0.3-test.10

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.
@@ -15,7 +15,11 @@ export declare enum MessageStatuses {
15
15
  PROPOSED = "PROPOSED",
16
16
  CONFIRMED = "CONFIRMED",
17
17
  EXECUTION_SUCCESS = "EXECUTION_SUCCESS",
18
- EXECUTION_FAILURE = "EXECUTION_FAILURE"
18
+ EXECUTION_FAILURE = "EXECUTION_FAILURE",
19
+ VERIFIED = "VERIFIED",
20
+ ATTESTED = "ATTESTED",
21
+ EXECUTING = "EXECUTING",
22
+ INBOUND_REVERTING = "INBOUND_REVERTING"
19
23
  }
20
24
  export declare enum MessageStatusStep {
21
25
  RECEIVED = 0,
@@ -21,6 +21,10 @@ var MessageStatuses;
21
21
  MessageStatuses["CONFIRMED"] = "CONFIRMED";
22
22
  MessageStatuses["EXECUTION_SUCCESS"] = "EXECUTION_SUCCESS";
23
23
  MessageStatuses["EXECUTION_FAILURE"] = "EXECUTION_FAILURE";
24
+ MessageStatuses["VERIFIED"] = "VERIFIED";
25
+ MessageStatuses["ATTESTED"] = "ATTESTED";
26
+ MessageStatuses["EXECUTING"] = "EXECUTING";
27
+ MessageStatuses["INBOUND_REVERTING"] = "INBOUND_REVERTING";
24
28
  })(MessageStatuses || (exports.MessageStatuses = MessageStatuses = {}));
25
29
  var MessageStatusStep;
26
30
  (function (MessageStatusStep) {
@@ -1,6 +1,6 @@
1
1
  import { TripReason } from "../models";
2
2
  import { StatusCodes } from "./enums";
3
- import { ChainSlug, IntegrationTypes } from "@socket.tech/dl-core";
3
+ import { 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",
@@ -84,7 +84,7 @@ export interface ExecuteSigResponse {
84
84
  }
85
85
  export interface AttestRequest {
86
86
  switchboardAddress: string;
87
- dstChainSlug: ChainSlug;
87
+ dstChainSlug: number;
88
88
  packetId: string;
89
89
  root: string;
90
90
  proposalCount: number;
@@ -94,6 +94,8 @@ export interface AttestSuccess {
94
94
  packetId: string;
95
95
  proposalCount: number;
96
96
  signature: string;
97
+ digest: string;
98
+ signerAddress: string;
97
99
  }
98
100
  export interface AttestFailure {
99
101
  proposalValid: false;
@@ -102,3 +104,14 @@ export interface AttestFailure {
102
104
  reason: TripReason;
103
105
  }
104
106
  export type AttestResponse = AttestSuccess | AttestFailure;
107
+ export type MessageData = {
108
+ messageId: string;
109
+ destPlug: string;
110
+ srcPlug: string;
111
+ dstChainSlug: number;
112
+ srcChainSlug: number;
113
+ payload: string;
114
+ minMsgGasLimit: string;
115
+ executionParams: string;
116
+ packedMessage: string;
117
+ };
@@ -15,7 +15,6 @@ const getWaitTime = (integrationType, srcChainSlug, dstChainSlug) => {
15
15
  return (_b = (_a = exports.NativeWaitTime[srcChainSlug]) === null || _a === void 0 ? void 0 : _a[dstChainSlug]) !== null && _b !== void 0 ? _b : 2 * 3600;
16
16
  default:
17
17
  return 0;
18
- break;
19
18
  }
20
19
  };
21
20
  exports.getWaitTime = getWaitTime;
@@ -3,3 +3,4 @@ export * from "./message";
3
3
  export * from "./attestSignature";
4
4
  export * from "./attestation";
5
5
  export * from "./proposal";
6
+ export * from "./switchboard";
@@ -19,3 +19,4 @@ __exportStar(require("./message"), exports);
19
19
  __exportStar(require("./attestSignature"), exports);
20
20
  __exportStar(require("./attestation"), exports);
21
21
  __exportStar(require("./proposal"), exports);
22
+ __exportStar(require("./switchboard"), exports);
@@ -0,0 +1,61 @@
1
+ import { IntegrationTypes } from "@socket.tech/dl-core";
2
+ import { DataTypes, Model } from "sequelize";
3
+ export declare enum CapacitorType {
4
+ singleCapacitor = "1",
5
+ hashChainCapacitor = "2"
6
+ }
7
+ export declare class Switchboard extends Model {
8
+ id: number;
9
+ srcChainSlug: number;
10
+ dstChainSlug: number;
11
+ maxPacketLength: number;
12
+ srcSwitchboard: string;
13
+ dstSwitchboard: string;
14
+ srcCapacitor: string;
15
+ capacitorType: CapacitorType;
16
+ isEnabled: boolean;
17
+ integrationType: IntegrationTypes;
18
+ }
19
+ export declare const SwitchboardModel: {
20
+ id: {
21
+ type: DataTypes.IntegerDataTypeConstructor;
22
+ autoIncrement: boolean;
23
+ primaryKey: boolean;
24
+ };
25
+ srcChainSlug: {
26
+ type: DataTypes.IntegerDataTypeConstructor;
27
+ unique: string;
28
+ };
29
+ dstChainSlug: {
30
+ type: DataTypes.IntegerDataTypeConstructor;
31
+ unique: string;
32
+ };
33
+ maxPacketLength: {
34
+ type: DataTypes.IntegerDataTypeConstructor;
35
+ };
36
+ srcSwitchboard: {
37
+ type: DataTypes.StringDataTypeConstructor;
38
+ unique: string;
39
+ };
40
+ dstSwitchboard: {
41
+ type: DataTypes.StringDataTypeConstructor;
42
+ };
43
+ srcCapacitor: {
44
+ type: DataTypes.StringDataTypeConstructor;
45
+ };
46
+ capacitorType: {
47
+ type: DataTypes.EnumDataTypeConstructor;
48
+ values: CapacitorType[];
49
+ defaultValue: CapacitorType;
50
+ };
51
+ isEnabled: {
52
+ type: DataTypes.AbstractDataTypeConstructor;
53
+ defaultValue: boolean;
54
+ };
55
+ integrationType: {
56
+ type: DataTypes.EnumDataTypeConstructor;
57
+ values: IntegrationTypes[];
58
+ defaultValue: IntegrationTypes;
59
+ };
60
+ };
61
+ export declare const addSwitchboardHooks: () => Promise<void>;
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addSwitchboardHooks = exports.SwitchboardModel = exports.Switchboard = exports.CapacitorType = void 0;
4
+ const dl_core_1 = require("@socket.tech/dl-core");
5
+ const sequelize_1 = require("sequelize");
6
+ var CapacitorType;
7
+ (function (CapacitorType) {
8
+ CapacitorType["singleCapacitor"] = "1";
9
+ CapacitorType["hashChainCapacitor"] = "2";
10
+ })(CapacitorType || (exports.CapacitorType = CapacitorType = {}));
11
+ class Switchboard extends sequelize_1.Model {
12
+ }
13
+ exports.Switchboard = Switchboard;
14
+ exports.SwitchboardModel = {
15
+ id: {
16
+ type: sequelize_1.DataTypes.INTEGER,
17
+ autoIncrement: true,
18
+ primaryKey: true,
19
+ },
20
+ srcChainSlug: {
21
+ type: sequelize_1.DataTypes.INTEGER,
22
+ unique: "uniqueSwitchboardPointer",
23
+ },
24
+ dstChainSlug: {
25
+ type: sequelize_1.DataTypes.INTEGER,
26
+ unique: "uniqueSwitchboardPointer",
27
+ },
28
+ maxPacketLength: {
29
+ type: sequelize_1.DataTypes.INTEGER,
30
+ },
31
+ srcSwitchboard: {
32
+ type: sequelize_1.DataTypes.STRING,
33
+ unique: "uniqueSwitchboardPointer",
34
+ },
35
+ dstSwitchboard: {
36
+ type: sequelize_1.DataTypes.STRING,
37
+ },
38
+ srcCapacitor: {
39
+ type: sequelize_1.DataTypes.STRING,
40
+ },
41
+ capacitorType: {
42
+ type: sequelize_1.DataTypes.ENUM,
43
+ values: [...Object.values(CapacitorType)],
44
+ defaultValue: CapacitorType.singleCapacitor,
45
+ },
46
+ isEnabled: {
47
+ type: sequelize_1.DataTypes.BOOLEAN,
48
+ defaultValue: false,
49
+ },
50
+ integrationType: {
51
+ type: sequelize_1.DataTypes.ENUM,
52
+ values: [...Object.values(dl_core_1.IntegrationTypes)],
53
+ defaultValue: dl_core_1.IntegrationTypes.unknown,
54
+ },
55
+ };
56
+ const addSwitchboardHooks = async () => {
57
+ Switchboard.beforeBulkCreate((switchboards, options) => {
58
+ for (let index = 0; index < switchboards.length; index++) {
59
+ switchboards[index] = processStrings(switchboards[index]);
60
+ }
61
+ });
62
+ Switchboard.beforeSave((switchboard, options) => {
63
+ switchboard = processStrings(switchboard);
64
+ });
65
+ };
66
+ exports.addSwitchboardHooks = addSwitchboardHooks;
67
+ function processStrings(switchboard) {
68
+ if (switchboard.srcSwitchboard)
69
+ switchboard.srcSwitchboard = switchboard.srcSwitchboard.toLowerCase();
70
+ if (switchboard.dstSwitchboard)
71
+ switchboard.dstSwitchboard = switchboard.dstSwitchboard.toLowerCase();
72
+ if (switchboard.srcCapacitor)
73
+ switchboard.srcCapacitor = switchboard.srcCapacitor.toLowerCase();
74
+ return switchboard;
75
+ }
@@ -0,0 +1,4 @@
1
+ import { Contract, Event, EventFilter, providers } from "ethers";
2
+ import { StaticJsonRpcProvider } from "@ethersproject/providers";
3
+ export declare const getEvents: (contract: Contract, filter: EventFilter | string, fromBlock: number, toBlock: number, eventBlockRange?: number) => Promise<Event[]>;
4
+ export declare const getLogs: (provider: StaticJsonRpcProvider, address: string[], topics: string[], fromBlock: number, toBlock: number, eventBlockRange?: number) => Promise<providers.Log[]>;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLogs = exports.getEvents = void 0;
4
+ const getEvents = async (contract, filter, fromBlock, toBlock, eventBlockRange = 5000) => {
5
+ const allEvents = [];
6
+ try {
7
+ let from = fromBlock;
8
+ let to = from + eventBlockRange - 1;
9
+ to = to < toBlock ? to : toBlock;
10
+ while (from <= toBlock) {
11
+ const events = await contract.queryFilter(filter, from, to);
12
+ allEvents.push(...events);
13
+ from = to + 1;
14
+ to = from + eventBlockRange - 1;
15
+ to = to < toBlock ? to : toBlock;
16
+ }
17
+ }
18
+ catch (error) {
19
+ throw error;
20
+ }
21
+ return allEvents;
22
+ };
23
+ exports.getEvents = getEvents;
24
+ const getLogs = async (provider, address, topics, fromBlock, toBlock, eventBlockRange = 5000) => {
25
+ const allLogs = [];
26
+ try {
27
+ let from = fromBlock;
28
+ let to = from + eventBlockRange - 1;
29
+ to = to < toBlock ? to : toBlock;
30
+ while (from <= toBlock) {
31
+ const logs = await provider.send("eth_getLogs", [
32
+ {
33
+ address,
34
+ topics,
35
+ fromBlock: `0x${from.toString(16)}`,
36
+ toBlock: `0x${to.toString(16)}`,
37
+ },
38
+ ]);
39
+ allLogs.push(...logs);
40
+ from = to + 1;
41
+ to = from + eventBlockRange - 1;
42
+ to = to < toBlock ? to : toBlock;
43
+ }
44
+ }
45
+ catch (error) {
46
+ throw error;
47
+ }
48
+ return allLogs;
49
+ };
50
+ exports.getLogs = getLogs;
@@ -5,6 +5,7 @@ export declare const isEmpty: (data: any) => boolean;
5
5
  export declare const checkMissingFields: (fields: {
6
6
  [key: string]: any;
7
7
  }) => void;
8
+ export declare const checkEnvValue: (key: string) => string;
8
9
  export declare const checkMissingFieldsAndType: (fields: {
9
10
  [key: string]: any;
10
11
  }, types?: {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.responseBody = exports.filterFields = exports.removeFields = exports.checkObjectFieldsAndType = exports.checkMissingFieldsAndType = exports.checkMissingFields = exports.isEmpty = void 0;
4
- const __1 = require("..");
3
+ exports.responseBody = exports.filterFields = exports.removeFields = exports.checkObjectFieldsAndType = exports.checkMissingFieldsAndType = exports.checkEnvValue = exports.checkMissingFields = exports.isEmpty = void 0;
4
+ const constants_1 = require("../constants");
5
5
  /**
6
6
  * defining functions.
7
7
  */
@@ -18,18 +18,26 @@ const checkMissingFields = (fields) => {
18
18
  for (const field in fields) {
19
19
  let value = fields[field];
20
20
  if (!value) {
21
- throw (0, __1.BadRequestError)(`missing field : ${field}`);
21
+ throw (0, constants_1.BadRequestError)(`missing field : ${field}`);
22
22
  }
23
23
  }
24
24
  };
25
25
  exports.checkMissingFields = checkMissingFields;
26
+ const checkEnvValue = (key) => {
27
+ let value = process.env[key];
28
+ if (!value) {
29
+ throw (0, constants_1.InternalServerError)(`${key} not found`);
30
+ }
31
+ return value;
32
+ };
33
+ exports.checkEnvValue = checkEnvValue;
26
34
  const checkMissingFieldsAndType = (fields, types = {}) => {
27
35
  for (const field in fields) {
28
36
  if ((0, exports.isEmpty)(fields[field])) {
29
- throw (0, __1.BadRequestError)(`missing field : ${field}`);
37
+ throw (0, constants_1.BadRequestError)(`missing field : ${field}`);
30
38
  }
31
39
  if (types[field] && typeof fields[field] !== types[field]) {
32
- throw (0, __1.BadRequestError)(`Type of ${field} expected : "${types[field]}", got : "${typeof fields[field]}"`);
40
+ throw (0, constants_1.BadRequestError)(`Type of ${field} expected : "${types[field]}", got : "${typeof fields[field]}"`);
33
41
  }
34
42
  }
35
43
  };
@@ -38,13 +46,13 @@ const checkObjectFieldsAndType = (data, types = {}, prefix = "") => {
38
46
  let keys = Object.keys(types);
39
47
  for (const key of keys) {
40
48
  if ((0, exports.isEmpty)(data[key])) {
41
- throw (0, __1.BadRequestError)(`missing field : ${prefix}.${key}`);
49
+ throw (0, constants_1.BadRequestError)(`missing field : ${prefix}.${key}`);
42
50
  }
43
51
  if (typeof data[key] === "object") {
44
52
  (0, exports.checkObjectFieldsAndType)(data[key], types[key], `${prefix}.${key}`);
45
53
  }
46
54
  else if (typeof data[key] !== types[key]) {
47
- throw (0, __1.BadRequestError)(`Type of ${prefix}.${key} expected : "${types[key]}", got : "${typeof data[key]}"`);
55
+ throw (0, constants_1.BadRequestError)(`Type of ${prefix}.${key} expected : "${types[key]}", got : "${typeof data[key]}"`);
48
56
  }
49
57
  }
50
58
  };
@@ -1,7 +1,7 @@
1
1
  export interface PacketDetails {
2
2
  chainSlug: number;
3
3
  capacitorAddr: string;
4
- packetNonce: string;
4
+ packetCount: string;
5
5
  }
6
6
  export interface MessageDetails {
7
7
  chainSlug: number;
@@ -10,5 +10,5 @@ export interface MessageDetails {
10
10
  }
11
11
  export declare const unpackPacketId: (packetId: string) => PacketDetails;
12
12
  export declare const unpackMessageId: (messageId: string) => MessageDetails;
13
- export declare const packPacketId: (chainSlug: number, capacitorAddr: string, packetNonce: string) => string;
13
+ export declare const packPacketId: (chainSlug: number, capacitorAddr: string, packetCount: string) => string;
14
14
  export declare function encodePacketId(chainSlug: number, capacitorAddress: string, packetCount: number): string;
@@ -9,11 +9,11 @@ const unpackPacketId = (packetId) => {
9
9
  const slugLength = packetId.length - 58;
10
10
  const chainSlug = parseInt(ethers_1.BigNumber.from(`0x${packetId.substring(2, 2 + slugLength)}`).toString());
11
11
  const capacitorAddr = (0, address_1.toLowerCase)(`0x${packetId.substring(2 + slugLength, 40 + 2 + slugLength)}`);
12
- const packetNonce = ethers_1.BigNumber.from(`0x${packetId.substring(40 + 2 + slugLength)}`).toString();
12
+ const packetCount = ethers_1.BigNumber.from(`0x${packetId.substring(40 + 2 + slugLength)}`).toString();
13
13
  return {
14
14
  chainSlug,
15
15
  capacitorAddr,
16
- packetNonce,
16
+ packetCount,
17
17
  };
18
18
  };
19
19
  exports.unpackPacketId = unpackPacketId;
@@ -30,8 +30,8 @@ const unpackMessageId = (messageId) => {
30
30
  };
31
31
  };
32
32
  exports.unpackMessageId = unpackMessageId;
33
- const packPacketId = (chainSlug, capacitorAddr, packetNonce) => {
34
- const nonce = ethers_1.BigNumber.from(packetNonce).toHexString();
33
+ const packPacketId = (chainSlug, capacitorAddr, packetCount) => {
34
+ const nonce = ethers_1.BigNumber.from(packetCount).toHexString();
35
35
  const nonceHex = nonce.length <= 16 ? (0, utils_1.hexZeroPad)(nonce, 8).substring(2) : nonce.substring(2);
36
36
  const slug = ethers_1.BigNumber.from(chainSlug).toHexString();
37
37
  const slugHex = slug.length <= 10 ? (0, utils_1.hexZeroPad)(slug, 4) : slug;
@@ -7,3 +7,5 @@ export * from "./dataStructHelper";
7
7
  export * from "./extraUtils";
8
8
  export * from "./time";
9
9
  export * from "./ethersAwsKmsSigner";
10
+ export * from "./secretManagerService";
11
+ export * from "./eventGetter";
@@ -23,3 +23,5 @@ __exportStar(require("./dataStructHelper"), exports);
23
23
  __exportStar(require("./extraUtils"), exports);
24
24
  __exportStar(require("./time"), exports);
25
25
  __exportStar(require("./ethersAwsKmsSigner"), exports);
26
+ __exportStar(require("./secretManagerService"), exports);
27
+ __exportStar(require("./eventGetter"), exports);
@@ -2,17 +2,15 @@ import { Provider, TransactionRequest, TransactionResponse } from "@ethersprojec
2
2
  import { Signer } from "@ethersproject/abstract-signer";
3
3
  import { Bytes } from "@ethersproject/bytes";
4
4
  import { Deferrable } from "@ethersproject/properties";
5
- import { ChainSlug } from "@socket.tech/dl-core";
6
5
  export declare class SocketRelaySigner extends Signer {
7
6
  readonly provider: Provider;
8
- readonly chainSlug: ChainSlug;
7
+ readonly chainId: number;
9
8
  readonly relayUrl: string;
10
9
  readonly relayerAPIKey: string;
11
10
  readonly sequential: boolean;
12
11
  readonly isCritical: boolean;
13
12
  readonly metadata: object;
14
- readonly source: string;
15
- constructor(provider: Provider, chainSlug: ChainSlug, relayUrl: string, relayerAPIKey: string, sequential?: boolean, isCritical?: boolean, metadata?: object, source?: string);
13
+ constructor(provider: Provider, chainId: number, relayUrl: string, relayerAPIKey: string, sequential?: boolean, isCritical?: boolean, metadata?: object);
16
14
  getAddress(): Promise<string>;
17
15
  signMessage(message: string | Bytes): Promise<string>;
18
16
  connect(provider: Provider): SocketRelaySigner;
@@ -3,21 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SocketRelaySigner = void 0;
4
4
  const abstract_signer_1 = require("@ethersproject/abstract-signer");
5
5
  const axios_1 = require("./axios");
6
- const dl_core_1 = require("@socket.tech/dl-core");
7
6
  class SocketRelaySigner extends abstract_signer_1.Signer {
8
- constructor(provider, chainSlug, relayUrl, relayerAPIKey, sequential = false,
7
+ constructor(provider, chainId, relayUrl, relayerAPIKey, sequential = false,
9
8
  // if isCritical is set to true, will try multiple relayers
10
9
  // to get the transaction included
11
- isCritical = false, metadata = {}, source = "Attester") {
10
+ isCritical = false, metadata = {}) {
12
11
  super();
13
12
  this.provider = provider;
14
- this.chainSlug = chainSlug;
13
+ this.chainId = chainId;
15
14
  this.relayUrl = relayUrl;
16
15
  this.relayerAPIKey = relayerAPIKey;
17
16
  this.sequential = sequential;
18
17
  this.isCritical = isCritical;
19
18
  this.metadata = metadata;
20
- this.source = source;
21
19
  }
22
20
  async getAddress() {
23
21
  // some random address
@@ -27,13 +25,13 @@ class SocketRelaySigner extends abstract_signer_1.Signer {
27
25
  throw new Error(" signMessage not Implemented");
28
26
  }
29
27
  connect(provider) {
30
- return new SocketRelaySigner(provider, this.chainSlug, this.relayUrl, this.relayerAPIKey, this.sequential, this.isCritical, this.metadata);
28
+ return new SocketRelaySigner(provider, this.chainId, this.relayUrl, this.relayerAPIKey, this.sequential, this.isCritical, this.metadata);
31
29
  }
32
30
  setCritical(isCritical) {
33
- return new SocketRelaySigner(this.provider, this.chainSlug, this.relayUrl, this.relayerAPIKey, this.sequential, isCritical, this.metadata);
31
+ return new SocketRelaySigner(this.provider, this.chainId, this.relayUrl, this.relayerAPIKey, this.sequential, isCritical, this.metadata);
34
32
  }
35
33
  addMetadata(metadata) {
36
- return new SocketRelaySigner(this.provider, this.chainSlug, this.relayUrl, this.relayerAPIKey, this.sequential, this.isCritical, metadata);
34
+ return new SocketRelaySigner(this.provider, this.chainId, this.relayUrl, this.relayerAPIKey, this.sequential, this.isCritical, metadata);
37
35
  }
38
36
  async signTransaction(transaction) {
39
37
  throw new Error(" signTransaction not Implemented");
@@ -45,10 +43,9 @@ class SocketRelaySigner extends abstract_signer_1.Signer {
45
43
  if (!this.relayUrl)
46
44
  throw new Error("relayUrl not provided");
47
45
  let payload = {
48
- chainId: dl_core_1.ChainSlugToId[this.chainSlug],
46
+ chainId: this.chainId,
49
47
  sequential: this.sequential,
50
48
  isCritical: this.isCritical,
51
- source: this.source,
52
49
  metadata: this.metadata,
53
50
  ...transaction,
54
51
  };
@@ -0,0 +1,2 @@
1
+ export declare const getAllSecrets: (secretName: string, region?: string) => Promise<any>;
2
+ export declare const getSecret: (secretName: string, secretKey: string, region?: string) => Promise<any>;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSecret = exports.getAllSecrets = void 0;
4
+ const client_secrets_manager_1 = require("@aws-sdk/client-secrets-manager");
5
+ const defaultRegion = "us-east-1";
6
+ const getAllSecrets = async (secretName, region = defaultRegion) => {
7
+ try {
8
+ const client = new client_secrets_manager_1.SecretsManagerClient({
9
+ region,
10
+ });
11
+ let response = await client.send(new client_secrets_manager_1.GetSecretValueCommand({
12
+ SecretId: secretName,
13
+ VersionStage: "AWSCURRENT", // VersionStage defaults to AWSCURRENT if unspecified
14
+ }));
15
+ if (!(response === null || response === void 0 ? void 0 : response.SecretString))
16
+ throw new Error("No secret found");
17
+ return JSON.parse(response.SecretString);
18
+ }
19
+ catch (error) {
20
+ throw error;
21
+ }
22
+ };
23
+ exports.getAllSecrets = getAllSecrets;
24
+ const getSecret = async (secretName, secretKey, region = defaultRegion) => {
25
+ try {
26
+ let secrets = await (0, exports.getAllSecrets)(secretName, region);
27
+ return secrets === null || secrets === void 0 ? void 0 : secrets[secretKey];
28
+ }
29
+ catch (error) {
30
+ throw error;
31
+ }
32
+ };
33
+ exports.getSecret = getSecret;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socket.tech/dl-common",
3
- "version": "1.0.3-test.1",
3
+ "version": "1.0.3-test.10",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "description": "common utilities for socket data layer.",
@@ -20,7 +20,7 @@
20
20
  "start": "serverless offline start --reloadHandler -s dev",
21
21
  "start:dev": "serverless offline start --reloadHandler -s dev",
22
22
  "deploy": "npx sls deploy -s dev --verbose",
23
- "deploy:prod": "npx sls deploy -s prod --verbose",
23
+ "deploy:prod": "export AWS_PROFILE=dlprod && npx sls deploy -s prod --verbose",
24
24
  "deploy:surge": "npx sls deploy -s surge --verbose",
25
25
  "build": "tsc --project lib.tsconfig.json",
26
26
  "build:clean": "rm -rf tsconfig.build.tsbuildinfo && rm -rf ./dist",
@@ -30,12 +30,15 @@
30
30
  "prettier:fix": "npx prettier src dl-common --write ./**/*.{ts,js,json,yml,md}",
31
31
  "format": "prettier \"./**\" --write --ignore-unknown",
32
32
  "format:check": "prettier \"./**\" --ignore-unknown --check",
33
- "prepare": "husky install"
33
+ "prepare": "husky install",
34
+ "publishp": "yarn lint && yarn build"
34
35
  },
35
36
  "dependencies": {
37
+ "@aws-sdk/client-secrets-manager": "^3.433.0",
36
38
  "@aws-sdk/client-sqs": "^3.421.0",
37
39
  "@aws-sdk/smithy-client": "^3.329.0",
38
- "@socket.tech/dl-core": "2.4.8-test.1",
40
+ "@ethersproject/providers": "^5.7.2",
41
+ "@socket.tech/dl-core": "2.4.10",
39
42
  "@socket.tech/ll-common": "^0.0.19",
40
43
  "async-redis": "^2.0.0",
41
44
  "ethers": "^5.7.1",