@riocrypto/common-server 1.0.2756 → 1.0.2757

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,8 +1,9 @@
1
1
  declare class CosignerClient {
2
2
  private apiKey;
3
3
  private webhookSecret;
4
+ private requestToken;
4
5
  private axiosClient;
5
- constructor(apiKey: string, webhookSecret: string);
6
+ constructor(apiKey: string, webhookSecret: string, requestToken: string);
6
7
  sendRequest(title: string, description: string, minApprovers: number, notificationUrl: string, approverGroupId: string, metadata?: Object, alternativeActions?: {
7
8
  label: string;
8
9
  value: string;
@@ -17,9 +17,10 @@ const secret_manager_client_1 = require("./secret-manager-client");
17
17
  const axios_with_logging_1 = require("./axios-with-logging");
18
18
  const crypto_1 = __importDefault(require("crypto"));
19
19
  class CosignerClient {
20
- constructor(apiKey, webhookSecret) {
20
+ constructor(apiKey, webhookSecret, requestToken) {
21
21
  this.apiKey = apiKey;
22
22
  this.webhookSecret = webhookSecret;
23
+ this.requestToken = requestToken;
23
24
  this.axiosClient = (0, axios_with_logging_1.buildAxiosWithLogging)();
24
25
  }
25
26
  sendRequest(title, description, minApprovers, notificationUrl, approverGroupId, metadata, alternativeActions) {
@@ -35,6 +36,7 @@ class CosignerClient {
35
36
  }, {
36
37
  headers: {
37
38
  "x-api-key": this.apiKey,
39
+ "x-cosigner-token": this.requestToken,
38
40
  },
39
41
  });
40
42
  });
@@ -58,6 +60,10 @@ const buildCosignerClient = () => __awaiter(void 0, void 0, void 0, function* ()
58
60
  if (!COSIGNER_WEBHOOK_SECRET) {
59
61
  throw new Error("Unable to get COSIGNER_WEBHOOK_SECRET");
60
62
  }
61
- return new CosignerClient(COSIGNER_API_KEY, COSIGNER_WEBHOOK_SECRET);
63
+ const COSIGNER_REQUEST_TOKEN = yield secret_manager_client_1.secretManagerClient.getSecretValue("COSIGNER_REQUEST_TOKEN");
64
+ if (!COSIGNER_REQUEST_TOKEN) {
65
+ throw new Error("Unable to get COSIGNER_REQUEST_TOKEN");
66
+ }
67
+ return new CosignerClient(COSIGNER_API_KEY, COSIGNER_WEBHOOK_SECRET, COSIGNER_REQUEST_TOKEN);
62
68
  });
63
69
  exports.buildCosignerClient = buildCosignerClient;
package/package.json CHANGED
@@ -1,16 +1,12 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.2756",
3
+ "version": "1.0.2757",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
7
7
  "files": [
8
8
  "build/**/*"
9
9
  ],
10
- "scripts": {
11
- "clean": "rm -rf ./build/*",
12
- "build": "npm run clean && tsc"
13
- },
14
10
  "keywords": [],
15
11
  "author": "",
16
12
  "license": "ISC",
@@ -47,5 +43,9 @@
47
43
  "uuid": "^9.0.1",
48
44
  "winston": "^3.19.0",
49
45
  "xss": "^1.0.15"
46
+ },
47
+ "scripts": {
48
+ "clean": "rm -rf ./build/*",
49
+ "build": "npm run clean && tsc"
50
50
  }
51
- }
51
+ }