@riocrypto/common-server 1.0.851 → 1.0.852

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.
@@ -0,0 +1,8 @@
1
+ declare class BridgeClient {
2
+ private apiKey;
3
+ private baseUrl;
4
+ constructor(apiKey: string);
5
+ getTermsOfServiceUrl(): Promise<string>;
6
+ }
7
+ export declare const buildBridgeClient: () => Promise<BridgeClient>;
8
+ export {};
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.buildBridgeClient = void 0;
16
+ const secret_manager_client_1 = require("./secret-manager-client");
17
+ const axios_1 = __importDefault(require("axios"));
18
+ const common_1 = require("@riocrypto/common");
19
+ const uuid_1 = require("uuid");
20
+ class BridgeClient {
21
+ constructor(apiKey) {
22
+ this.apiKey = apiKey;
23
+ if ([common_1.RioEnv.Development, common_1.RioEnv.Production, common_1.RioEnv.Staging].includes(process.env.RIO_ENV)) {
24
+ this.baseUrl = "https://api.bridge.xyz";
25
+ }
26
+ else {
27
+ this.baseUrl = "https://api.sandbox.bridge.xyz";
28
+ }
29
+ }
30
+ getTermsOfServiceUrl() {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ const { data } = yield axios_1.default.post(`${this.baseUrl}/v0/customers/tos_links`, {
33
+ headers: {
34
+ "Api-Key": this.apiKey,
35
+ "Idempotency-Key": (0, uuid_1.v4)(),
36
+ },
37
+ });
38
+ return data.url;
39
+ });
40
+ }
41
+ }
42
+ const buildBridgeClient = () => __awaiter(void 0, void 0, void 0, function* () {
43
+ // Retrieve secrets asynchronously
44
+ const BRIDGE_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("BRIDGE_API_KEY");
45
+ if (!BRIDGE_API_KEY) {
46
+ throw new Error("Unable to get BRIDGE_API_KEY");
47
+ }
48
+ // Create GuenoClient instance and return
49
+ return new BridgeClient(BRIDGE_API_KEY);
50
+ });
51
+ exports.buildBridgeClient = buildBridgeClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.851",
3
+ "version": "1.0.852",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  "@aws-sdk/client-s3": "^3.297.0",
25
25
  "@everapi/currencyapi-js": "^1.0.6",
26
26
  "@google-cloud/storage": "^6.9.5",
27
- "@riocrypto/common": "^1.0.736",
27
+ "@riocrypto/common": "^1.0.737",
28
28
  "@types/express": "^4.17.13",
29
29
  "axios": "^0.27.2",
30
30
  "ccxt": "^3.0.30",