@riocrypto/common-server 1.0.1110 → 1.0.1112

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,13 @@
1
+ import { User } from "@riocrypto/common";
2
+ declare class KillbClient {
3
+ private apiKey;
4
+ private username;
5
+ private password;
6
+ private baseUrl;
7
+ constructor(apiKey: string, username: string, password: string);
8
+ getBearerToken(): Promise<string>;
9
+ createUser(user: User): Promise<string>;
10
+ formatDateToYYYYMMDD(date: Date): string;
11
+ }
12
+ export declare const buildKillbClient: () => Promise<KillbClient>;
13
+ export {};
@@ -0,0 +1,76 @@
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.buildKillbClient = 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
+ class KillbClient {
20
+ constructor(apiKey, username, password) {
21
+ this.apiKey = apiKey;
22
+ this.username = username;
23
+ this.password = password;
24
+ if ([common_1.RioEnv.Production, common_1.RioEnv.Staging].includes(process.env.RIO_ENV)) {
25
+ this.baseUrl = "https://sandbox.killb.app";
26
+ }
27
+ else {
28
+ this.baseUrl = "https://sandbox.killb.app";
29
+ }
30
+ }
31
+ getBearerToken() {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ const { data } = yield axios_1.default.post(`${this.baseUrl}/api/v1/auth/login`, {
34
+ email: this.username,
35
+ paassword: this.password,
36
+ }, {
37
+ headers: {
38
+ "Api-Key": this.apiKey,
39
+ },
40
+ });
41
+ return data.data.accessToken;
42
+ });
43
+ }
44
+ createUser(user) {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ const dateOfBirth = this.formatDateToYYYYMMDD(new Date(user.birthday));
47
+ const { data } = yield axios_1.default.post(`${this.baseUrl}/api/v1/auth/login`, {
48
+ email: this.username,
49
+ paassword: this.password,
50
+ }, {
51
+ headers: {
52
+ "Api-Key": this.apiKey,
53
+ },
54
+ });
55
+ return data.data.accessToken;
56
+ });
57
+ }
58
+ formatDateToYYYYMMDD(date) {
59
+ const year = date.getFullYear();
60
+ const month = (date.getMonth() + 1).toString().padStart(2, "0"); // Month is zero-based
61
+ const day = date.getDate().toString().padStart(2, "0");
62
+ return `${year}-${month}-${day}`;
63
+ }
64
+ }
65
+ const buildKillbClient = () => __awaiter(void 0, void 0, void 0, function* () {
66
+ // Retrieve secrets asynchronously
67
+ const KILLB_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("KILLB_API_KEY");
68
+ const KILLB_USERNAME = yield secret_manager_client_1.secretManagerClient.getSecretValue("KILLB_USERNAME");
69
+ const KILLB_PASSWORD = yield secret_manager_client_1.secretManagerClient.getSecretValue("KILLB_PASSWORD");
70
+ if (!KILLB_API_KEY || !KILLB_USERNAME || !KILLB_PASSWORD) {
71
+ throw new common_1.SecretManagerError();
72
+ }
73
+ // Create GuenoClient instance and return
74
+ return new KillbClient(KILLB_API_KEY, KILLB_USERNAME, KILLB_PASSWORD);
75
+ });
76
+ exports.buildKillbClient = buildKillbClient;
@@ -13,8 +13,9 @@ exports.getProcessorFees = void 0;
13
13
  const common_1 = require("@riocrypto/common");
14
14
  const getProcessorFees = (processor, amountFiat, conversionRateFromUSD) => __awaiter(void 0, void 0, void 0, function* () {
15
15
  if (processor === common_1.Processor.Bridge) {
16
- return ((amountFiat * (1 / conversionRateFromUSD) * 0.00015 + 20) *
17
- conversionRateFromUSD);
16
+ const x = (amountFiat * (1 / conversionRateFromUSD) * 0.0015 + 20) *
17
+ conversionRateFromUSD;
18
+ return x;
18
19
  }
19
20
  else if (processor === common_1.Processor.Kapstar) {
20
21
  return amountFiat * 0.006;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1110",
3
+ "version": "1.0.1112",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",