@riocrypto/common-server 1.0.1056 → 1.0.1058
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.
|
@@ -13,6 +13,7 @@ declare class FireblocksClient {
|
|
|
13
13
|
getDepositAddress(vaultId: string, crypto: Crypto): Promise<string>;
|
|
14
14
|
createVault(userId: string, name: string): Promise<string>;
|
|
15
15
|
createWallet(vaultId: string, crypto: Crypto): Promise<string>;
|
|
16
|
+
internalTransfer(crypto: Crypto, sourceVaultId: string, destinationVaultId: string, amountCrypto: number): Promise<string>;
|
|
16
17
|
sweep(vaultId: string, assetId: string, amount: number): Promise<void>;
|
|
17
18
|
}
|
|
18
19
|
export declare const buildFireblocksClient: () => Promise<FireblocksClient>;
|
|
@@ -138,6 +138,24 @@ class FireblocksClient {
|
|
|
138
138
|
return wallet.address;
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
|
+
internalTransfer(crypto, sourceVaultId, destinationVaultId, amountCrypto) {
|
|
142
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
+
const response = yield this.fireblocks.createTransaction({
|
|
144
|
+
assetId: crypto,
|
|
145
|
+
source: {
|
|
146
|
+
type: fireblocks_sdk_1.PeerType.VAULT_ACCOUNT,
|
|
147
|
+
id: sourceVaultId,
|
|
148
|
+
},
|
|
149
|
+
destination: {
|
|
150
|
+
type: fireblocks_sdk_1.PeerType.VAULT_ACCOUNT,
|
|
151
|
+
id: destinationVaultId,
|
|
152
|
+
},
|
|
153
|
+
amount: amountCrypto,
|
|
154
|
+
operation: fireblocks_sdk_1.TransactionOperation.TRANSFER,
|
|
155
|
+
});
|
|
156
|
+
return response.id;
|
|
157
|
+
});
|
|
158
|
+
}
|
|
141
159
|
sweep(vaultId, assetId, amount) {
|
|
142
160
|
return __awaiter(this, void 0, void 0, function* () {
|
|
143
161
|
yield this.fireblocks.createTransaction({
|
|
@@ -1,30 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.buildWebhookRegistration = void 0;
|
|
27
|
-
const crypto = __importStar(require("crypto"));
|
|
28
4
|
const buildWebhookRegistration = (mongoose) => {
|
|
29
5
|
// if model is already defined, return it
|
|
30
6
|
if (mongoose.models.WebhookRegistration) {
|
|
@@ -59,17 +35,6 @@ const buildWebhookRegistration = (mongoose) => {
|
|
|
59
35
|
WebhookRegistrationSchema.statics.build = (attrs) => {
|
|
60
36
|
return new WebhookRegistration(attrs);
|
|
61
37
|
};
|
|
62
|
-
WebhookRegistrationSchema.pre("save", function (next) {
|
|
63
|
-
// Encrypt the shared secret before saving
|
|
64
|
-
const algorithm = "aes-256-cbc";
|
|
65
|
-
const iv = crypto.randomBytes(16);
|
|
66
|
-
const sharedSecret = this.get("encryptedSharedSecret");
|
|
67
|
-
const cipher = crypto.createCipheriv(algorithm, Buffer.from(sharedSecret), iv);
|
|
68
|
-
let encryptedSecret = cipher.update(sharedSecret, "utf8", "hex");
|
|
69
|
-
encryptedSecret += cipher.final("hex");
|
|
70
|
-
this.set("encryptedSharedSecret", encryptedSecret);
|
|
71
|
-
next();
|
|
72
|
-
});
|
|
73
38
|
const WebhookRegistration = mongoose.model("WebhookRegistration", WebhookRegistrationSchema);
|
|
74
39
|
return WebhookRegistration;
|
|
75
40
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1058",
|
|
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.
|
|
27
|
+
"@riocrypto/common": "^1.0.908",
|
|
28
28
|
"@types/express": "^4.17.13",
|
|
29
29
|
"axios": "^0.27.2",
|
|
30
30
|
"ccxt": "^3.0.30",
|