@bitpay-labs/bitcore-wallet-service 11.11.0 → 11.11.1

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.
Files changed (107) hide show
  1. package/package.json +4 -4
  2. package/src/config.ts +0 -20
  3. package/src/externalservices/banxa.ts +51 -10
  4. package/src/externalservices/changelly.ts +54 -6
  5. package/src/externalservices/moonpay.ts +85 -19
  6. package/src/externalservices/oneInch.ts +13 -5
  7. package/src/externalservices/ramp.ts +42 -8
  8. package/src/externalservices/sardine.ts +51 -10
  9. package/src/externalservices/simplex.ts +58 -11
  10. package/src/externalservices/thorswap.ts +46 -11
  11. package/src/externalservices/transak.ts +53 -11
  12. package/src/lib/routes/services.ts +0 -12
  13. package/src/lib/server.ts +0 -3
  14. package/src/types/externalservices.d.ts +0 -1
  15. package/test/integration/externalservices/banxa.test.ts +95 -5
  16. package/test/integration/externalservices/changelly.test.ts +118 -6
  17. package/test/integration/externalservices/coinGecko.test.ts +4 -0
  18. package/test/integration/externalservices/moonpay.test.ts +178 -9
  19. package/test/integration/externalservices/oneInch.test.ts +28 -1
  20. package/test/integration/externalservices/ramp.test.ts +126 -4
  21. package/test/integration/externalservices/sardine.test.ts +95 -5
  22. package/test/integration/externalservices/simplex.test.ts +95 -5
  23. package/test/integration/externalservices/thorswap.test.ts +81 -5
  24. package/test/integration/externalservices/transak.test.ts +98 -6
  25. package/test/integration/helpers.ts +1 -1
  26. package/test/integration/server.test.ts +56 -88
  27. package/ts_build/package.json +3 -3
  28. package/ts_build/src/config.d.ts.map +1 -1
  29. package/ts_build/src/config.js +0 -4
  30. package/ts_build/src/config.js.map +1 -1
  31. package/ts_build/src/externalservices/banxa.d.ts.map +1 -1
  32. package/ts_build/src/externalservices/banxa.js +51 -10
  33. package/ts_build/src/externalservices/banxa.js.map +1 -1
  34. package/ts_build/src/externalservices/changelly.d.ts.map +1 -1
  35. package/ts_build/src/externalservices/changelly.js +54 -6
  36. package/ts_build/src/externalservices/changelly.js.map +1 -1
  37. package/ts_build/src/externalservices/moonpay.d.ts.map +1 -1
  38. package/ts_build/src/externalservices/moonpay.js +85 -19
  39. package/ts_build/src/externalservices/moonpay.js.map +1 -1
  40. package/ts_build/src/externalservices/oneInch.d.ts.map +1 -1
  41. package/ts_build/src/externalservices/oneInch.js +13 -5
  42. package/ts_build/src/externalservices/oneInch.js.map +1 -1
  43. package/ts_build/src/externalservices/ramp.d.ts.map +1 -1
  44. package/ts_build/src/externalservices/ramp.js +42 -8
  45. package/ts_build/src/externalservices/ramp.js.map +1 -1
  46. package/ts_build/src/externalservices/sardine.d.ts.map +1 -1
  47. package/ts_build/src/externalservices/sardine.js +51 -10
  48. package/ts_build/src/externalservices/sardine.js.map +1 -1
  49. package/ts_build/src/externalservices/simplex.d.ts.map +1 -1
  50. package/ts_build/src/externalservices/simplex.js +55 -11
  51. package/ts_build/src/externalservices/simplex.js.map +1 -1
  52. package/ts_build/src/externalservices/thorswap.d.ts.map +1 -1
  53. package/ts_build/src/externalservices/thorswap.js +45 -11
  54. package/ts_build/src/externalservices/thorswap.js.map +1 -1
  55. package/ts_build/src/externalservices/transak.d.ts.map +1 -1
  56. package/ts_build/src/externalservices/transak.js +53 -11
  57. package/ts_build/src/externalservices/transak.js.map +1 -1
  58. package/ts_build/src/lib/routes/services.d.ts.map +1 -1
  59. package/ts_build/src/lib/routes/services.js +0 -10
  60. package/ts_build/src/lib/routes/services.js.map +1 -1
  61. package/ts_build/src/lib/server.d.ts +0 -2
  62. package/ts_build/src/lib/server.d.ts.map +1 -1
  63. package/ts_build/src/lib/server.js +0 -2
  64. package/ts_build/src/lib/server.js.map +1 -1
  65. package/ts_build/test/integration/externalservices/banxa.test.d.ts.map +1 -1
  66. package/ts_build/test/integration/externalservices/banxa.test.js +93 -5
  67. package/ts_build/test/integration/externalservices/banxa.test.js.map +1 -1
  68. package/ts_build/test/integration/externalservices/changelly.test.d.ts.map +1 -1
  69. package/ts_build/test/integration/externalservices/changelly.test.js +111 -6
  70. package/ts_build/test/integration/externalservices/changelly.test.js.map +1 -1
  71. package/ts_build/test/integration/externalservices/coinGecko.test.js +4 -0
  72. package/ts_build/test/integration/externalservices/coinGecko.test.js.map +1 -1
  73. package/ts_build/test/integration/externalservices/moonpay.test.d.ts.map +1 -1
  74. package/ts_build/test/integration/externalservices/moonpay.test.js +169 -9
  75. package/ts_build/test/integration/externalservices/moonpay.test.js.map +1 -1
  76. package/ts_build/test/integration/externalservices/oneInch.test.d.ts.map +1 -1
  77. package/ts_build/test/integration/externalservices/oneInch.test.js +26 -1
  78. package/ts_build/test/integration/externalservices/oneInch.test.js.map +1 -1
  79. package/ts_build/test/integration/externalservices/ramp.test.d.ts.map +1 -1
  80. package/ts_build/test/integration/externalservices/ramp.test.js +115 -4
  81. package/ts_build/test/integration/externalservices/ramp.test.js.map +1 -1
  82. package/ts_build/test/integration/externalservices/sardine.test.d.ts.map +1 -1
  83. package/ts_build/test/integration/externalservices/sardine.test.js +94 -5
  84. package/ts_build/test/integration/externalservices/sardine.test.js.map +1 -1
  85. package/ts_build/test/integration/externalservices/simplex.test.d.ts.map +1 -1
  86. package/ts_build/test/integration/externalservices/simplex.test.js +89 -5
  87. package/ts_build/test/integration/externalservices/simplex.test.js.map +1 -1
  88. package/ts_build/test/integration/externalservices/thorswap.test.d.ts.map +1 -1
  89. package/ts_build/test/integration/externalservices/thorswap.test.js +76 -5
  90. package/ts_build/test/integration/externalservices/thorswap.test.js.map +1 -1
  91. package/ts_build/test/integration/externalservices/transak.test.d.ts.map +1 -1
  92. package/ts_build/test/integration/externalservices/transak.test.js +93 -6
  93. package/ts_build/test/integration/externalservices/transak.test.js.map +1 -1
  94. package/ts_build/test/integration/helpers.js +1 -1
  95. package/ts_build/test/integration/helpers.js.map +1 -1
  96. package/ts_build/test/integration/server.test.js +44 -76
  97. package/ts_build/test/integration/server.test.js.map +1 -1
  98. package/src/externalservices/wyre.ts +0 -131
  99. package/test/integration/externalservices/wyre.test.ts +0 -270
  100. package/ts_build/src/externalservices/wyre.d.ts +0 -7
  101. package/ts_build/src/externalservices/wyre.d.ts.map +0 -1
  102. package/ts_build/src/externalservices/wyre.js +0 -144
  103. package/ts_build/src/externalservices/wyre.js.map +0 -1
  104. package/ts_build/test/integration/externalservices/wyre.test.d.ts +0 -2
  105. package/ts_build/test/integration/externalservices/wyre.test.d.ts.map +0 -1
  106. package/ts_build/test/integration/externalservices/wyre.test.js +0 -281
  107. package/ts_build/test/integration/externalservices/wyre.test.js.map +0 -1
@@ -1,131 +0,0 @@
1
- import { BitcoreLib as Bitcore } from '@bitpay-labs/crypto-wallet-core';
2
- import * as request from 'request';
3
- import config from '../config';
4
- import { ClientError } from '../lib/errors/clienterror';
5
- import { checkRequired } from '../lib/server';
6
-
7
- export class WyreService {
8
- request: any = request;
9
-
10
- private wyreGetKeys(req) {
11
- if (!config.wyre) throw new Error('Wyre missing credentials');
12
-
13
- let env = 'sandbox';
14
- if (req.body.env && req.body.env == 'production') {
15
- env = 'production';
16
- }
17
- delete req.body.env;
18
-
19
- const keys = {
20
- API: config.wyre[env].api,
21
- API_KEY: config.wyre[env].apiKey,
22
- SECRET_API_KEY: config.wyre[env].secretApiKey,
23
- ACCOUNT_ID: config.wyre[env].appProviderAccountId
24
- };
25
-
26
- return keys;
27
- }
28
-
29
- wyreWalletOrderQuotation(req): Promise<any> {
30
- return new Promise((resolve, reject) => {
31
- const keys = this.wyreGetKeys(req);
32
- req.body.accountId = keys.ACCOUNT_ID;
33
-
34
- if (req.body.amountIncludeFees) {
35
- if (
36
- !checkRequired(req.body, ['sourceAmount', 'sourceCurrency', 'destCurrency', 'dest', 'country', 'walletType'])
37
- ) {
38
- return reject(new ClientError("Wyre's request missing arguments"));
39
- }
40
- } else {
41
- if (!checkRequired(req.body, ['amount', 'sourceCurrency', 'destCurrency', 'dest', 'country'])) {
42
- return reject(new ClientError("Wyre's request missing arguments"));
43
- }
44
- }
45
-
46
- const URL: string = `${keys.API}/v3/orders/quote/partner?timestamp=${Date.now().toString()}`;
47
- const XApiSignature: string = URL + JSON.stringify(req.body);
48
- const XApiSignatureHash: string = Bitcore.crypto.Hash.sha256hmac(
49
- Buffer.from(XApiSignature),
50
- Buffer.from(keys.SECRET_API_KEY)
51
- ).toString('hex');
52
-
53
- const headers = {
54
- 'Content-Type': 'application/json',
55
- 'X-Api-Key': keys.API_KEY,
56
- 'X-Api-Signature': XApiSignatureHash
57
- };
58
-
59
- this.request.post(
60
- URL,
61
- {
62
- headers,
63
- body: req.body,
64
- json: true
65
- },
66
- (err, data) => {
67
- if (err) {
68
- return reject(err.body ? err.body : err);
69
- } else {
70
- return resolve(data.body);
71
- }
72
- }
73
- );
74
- });
75
- }
76
-
77
- wyreWalletOrderReservation(req): Promise<any> {
78
- return new Promise((resolve, reject) => {
79
- const keys = this.wyreGetKeys(req);
80
- req.body.referrerAccountId = keys.ACCOUNT_ID;
81
-
82
- if (req.body.amountIncludeFees) {
83
- if (
84
- !checkRequired(req.body, [
85
- 'sourceAmount',
86
- 'sourceCurrency',
87
- 'destCurrency',
88
- 'dest',
89
- 'country',
90
- 'paymentMethod'
91
- ])
92
- ) {
93
- return reject(new ClientError("Wyre's request missing arguments"));
94
- }
95
- } else {
96
- if (!checkRequired(req.body, ['amount', 'sourceCurrency', 'destCurrency', 'dest', 'paymentMethod'])) {
97
- return reject(new ClientError("Wyre's request missing arguments"));
98
- }
99
- }
100
-
101
- const URL: string = `${keys.API}/v3/orders/reserve?timestamp=${Date.now().toString()}`;
102
- const XApiSignature: string = URL + JSON.stringify(req.body);
103
- const XApiSignatureHash: string = Bitcore.crypto.Hash.sha256hmac(
104
- Buffer.from(XApiSignature),
105
- Buffer.from(keys.SECRET_API_KEY)
106
- ).toString('hex');
107
-
108
- const headers = {
109
- 'Content-Type': 'application/json',
110
- 'X-Api-Key': keys.API_KEY,
111
- 'X-Api-Signature': XApiSignatureHash
112
- };
113
-
114
- this.request.post(
115
- URL,
116
- {
117
- headers,
118
- body: req.body,
119
- json: true
120
- },
121
- (err, data) => {
122
- if (err) {
123
- return reject(err.body ? err.body : err);
124
- } else {
125
- return resolve(data.body);
126
- }
127
- }
128
- );
129
- });
130
- }
131
- }
@@ -1,270 +0,0 @@
1
- 'use strict';
2
-
3
- import * as chai from 'chai';
4
- import 'chai/register-should';
5
- import util from 'util';
6
- import { WalletService } from '../../../src/lib/server';
7
- import * as TestData from '../../testdata';
8
- import helpers from '../helpers';
9
- import config from '../../../src/config';
10
-
11
- const should = chai.should();
12
-
13
- describe('Wyre integration', () => {
14
- let server;
15
- let wallet;
16
- let fakeRequest;
17
- let req;
18
-
19
- before(async () => {
20
- await helpers.before();
21
- });
22
-
23
- beforeEach(async () => {
24
- config.wyre = {
25
- sandbox: {
26
- apiKey: 'xxxx',
27
- secretApiKey: 'xxxx',
28
- api: 'xxxx',
29
- widgetUrl: 'xxxx',
30
- appProviderAccountId: 'xxxx'
31
- },
32
- production: {
33
- apiKey: 'xxxx',
34
- secretApiKey: 'xxxx',
35
- api: 'xxxx',
36
- widgetUrl: 'xxxx',
37
- appProviderAccountId: 'xxxx'
38
- }
39
- };
40
-
41
- fakeRequest = {
42
- get: (_url, _opts, _cb) => { return _cb(null, { body: 'data' }); },
43
- post: (_url, _opts, _cb) => { return _cb(null, { body: 'data' }); },
44
- };
45
-
46
- await helpers.beforeEach();
47
- ({ wallet } = await helpers.createAndJoinWallet(1, 1));
48
- const priv = TestData.copayers[0].privKey_1H_0;
49
- const sig = helpers.signMessage('hello world', priv);
50
-
51
- (server = await util.promisify(WalletService.getInstanceWithAuth).call(WalletService, {
52
- // test assumes wallet's copayer[0] is TestData's copayer[0]
53
- copayerId: wallet.copayers[0].id,
54
- message: 'hello world',
55
- signature: sig,
56
- clientVersion: 'bwc-2.0.0',
57
- walletId: '123',
58
- }));
59
- });
60
-
61
- after(async () => {
62
- await helpers.after();
63
- });
64
-
65
- describe('#wyreWalletOrderQuotation', () => {
66
- beforeEach(() => {
67
- req = {
68
- headers: {},
69
- body: {
70
- env: 'sandbox',
71
- amount: 50,
72
- sourceCurrency: 'USD',
73
- destCurrency: 'BTC',
74
- dest: 'bitcoin:123123123',
75
- country: 'US'
76
- }
77
- };
78
- server.externalServices.wyre.request = fakeRequest;
79
- });
80
-
81
- it('should work properly if req is OK', async () => {
82
- const data = await server.externalServices.wyre.wyreWalletOrderQuotation(req);
83
- should.exist(data);
84
- });
85
-
86
- it('should return error if there is some missing arguments', async () => {
87
- delete req.body.amount;
88
-
89
- try {
90
- await server.externalServices.wyre.wyreWalletOrderQuotation(req);
91
- should.fail('should have thrown');
92
- } catch (err) {
93
- err.message.should.equal('Wyre\'s request missing arguments');
94
- }
95
- });
96
-
97
- it('should return error if post returns error', async () => {
98
- req.body.amount = 50;
99
- const fakeRequest2 = {
100
- post: (_url, _opts, _cb) => { return _cb(new Error('Error')); },
101
- };
102
-
103
- server.externalServices.wyre.request = fakeRequest2;
104
- try {
105
- await server.externalServices.wyre.wyreWalletOrderQuotation(req);
106
- should.fail('should have thrown');
107
- } catch (err) {
108
- err.message.should.equal('Error');
109
- }
110
- });
111
-
112
- it('should return error if Wyre is commented in config', async () => {
113
- config.wyre = undefined;
114
-
115
- try {
116
- await server.externalServices.wyre.wyreWalletOrderQuotation(req);
117
- should.fail('should have thrown');
118
- } catch (err) {
119
- err.message.should.equal('Wyre missing credentials');
120
- }
121
- });
122
-
123
- it('should return error if amountIncludeFees is true but sourceAmount is not present', async () => {
124
- req = {
125
- headers: {},
126
- body: {
127
- amountIncludeFees: true,
128
- env: 'sandbox',
129
- amount: 50,
130
- sourceCurrency: 'USD',
131
- destCurrency: 'BTC',
132
- dest: 'bitcoin:123123123',
133
- country: 'US',
134
- walletType: 'DEBIT_CARD'
135
- }
136
- };
137
-
138
- try {
139
- await server.externalServices.wyre.wyreWalletOrderQuotation(req);
140
- should.fail('should have thrown');
141
- } catch (err) {
142
- err.message.should.equal('Wyre\'s request missing arguments');
143
- }
144
- });
145
-
146
- it('should work properly if req is OK with amountIncludeFees and sourceAmount', async () => {
147
- req = {
148
- headers: {},
149
- body: {
150
- amountIncludeFees: true,
151
- env: 'sandbox',
152
- sourceAmount: 50,
153
- sourceCurrency: 'USD',
154
- destCurrency: 'BTC',
155
- dest: 'bitcoin:123123123',
156
- country: 'US',
157
- walletType: 'DEBIT_CARD'
158
- }
159
- };
160
-
161
- const data = await server.externalServices.wyre.wyreWalletOrderQuotation(req);
162
- should.exist(data);
163
- });
164
- });
165
-
166
- describe('#wyreWalletOrderReservation', () => {
167
- beforeEach(() => {
168
- req = {
169
- headers: {},
170
- body: {
171
- env: 'sandbox',
172
- amount: 50,
173
- sourceCurrency: 'USD',
174
- destCurrency: 'BTC',
175
- dest: 'bitcoin:123123123',
176
- paymentMethod: 'debit-card'
177
- }
178
- };
179
-
180
- fakeRequest = {
181
- post: (_url, _opts, _cb) => { return _cb(null, { body: {} }); },
182
- };
183
- server.externalServices.wyre.request = fakeRequest;
184
- });
185
-
186
- it('should work properly if req is OK', async () => {
187
- const data = await server.externalServices.wyre.wyreWalletOrderReservation(req);
188
- should.exist(data);
189
- });
190
-
191
- it('should return error if there is some missing arguments', async () => {
192
- delete req.body.amount;
193
-
194
- try {
195
- await server.externalServices.wyre.wyreWalletOrderReservation(req);
196
- should.fail('should have thrown');
197
- } catch (err) {
198
- err.message.should.equal('Wyre\'s request missing arguments');
199
- }
200
- });
201
-
202
- it('should return error if post returns error', async () => {
203
- req.body.amount = 50;
204
- const fakeRequest2 = {
205
- post: (_url, _opts, _cb) => { return _cb(new Error('Error')); },
206
- };
207
-
208
- server.externalServices.wyre.request = fakeRequest2;
209
- try {
210
- await server.externalServices.wyre.wyreWalletOrderReservation(req);
211
- should.fail('should have thrown');
212
- } catch (err) {
213
- err.message.should.equal('Error');
214
- }
215
- });
216
-
217
- it('should return error if Wyre is commented in config', async () => {
218
- config.wyre = undefined;
219
-
220
- try {
221
- await server.externalServices.wyre.wyreWalletOrderReservation(req);
222
- should.fail('should have thrown');
223
- } catch (err) {
224
- err.message.should.equal('Wyre missing credentials');
225
- }
226
- });
227
-
228
- it('should return error if amountIncludeFees is true but sourceAmount is not present', async () => {
229
- req = {
230
- headers: {},
231
- body: {
232
- amountIncludeFees: true,
233
- env: 'sandbox',
234
- amount: 50,
235
- sourceCurrency: 'USD',
236
- destCurrency: 'BTC',
237
- dest: 'bitcoin:123123123',
238
- country: 'US',
239
- paymentMethod: 'debit-card'
240
- }
241
- };
242
-
243
- try {
244
- await server.externalServices.wyre.wyreWalletOrderReservation(req);
245
- should.fail('should have thrown');
246
- } catch (err) {
247
- err.message.should.equal('Wyre\'s request missing arguments');
248
- }
249
- });
250
-
251
- it('should work properly if req is OK with amountIncludeFees and sourceAmount', async () => {
252
- req = {
253
- headers: {},
254
- body: {
255
- amountIncludeFees: true,
256
- env: 'sandbox',
257
- sourceAmount: 50,
258
- sourceCurrency: 'USD',
259
- destCurrency: 'BTC',
260
- dest: 'bitcoin:123123123',
261
- country: 'US',
262
- paymentMethod: 'debit-card'
263
- }
264
- };
265
-
266
- const data = await server.externalServices.wyre.wyreWalletOrderReservation(req);
267
- should.exist(data);
268
- });
269
- });
270
- });
@@ -1,7 +0,0 @@
1
- export declare class WyreService {
2
- request: any;
3
- private wyreGetKeys;
4
- wyreWalletOrderQuotation(req: any): Promise<any>;
5
- wyreWalletOrderReservation(req: any): Promise<any>;
6
- }
7
- //# sourceMappingURL=wyre.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wyre.d.ts","sourceRoot":"","sources":["../../../src/externalservices/wyre.ts"],"names":[],"mappings":"AAMA,qBAAa,WAAW;IACtB,OAAO,EAAE,GAAG,CAAW;IAEvB,OAAO,CAAC,WAAW;IAmBnB,wBAAwB,CAAC,GAAG,KAAA,GAAG,OAAO,CAAC,GAAG,CAAC;IAgD3C,0BAA0B,CAAC,GAAG,KAAA,GAAG,OAAO,CAAC,GAAG,CAAC;CAsD9C"}
@@ -1,144 +0,0 @@
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 () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.WyreService = void 0;
40
- const crypto_wallet_core_1 = require("@bitpay-labs/crypto-wallet-core");
41
- const request = __importStar(require("request"));
42
- const config_1 = __importDefault(require("../config"));
43
- const clienterror_1 = require("../lib/errors/clienterror");
44
- const server_1 = require("../lib/server");
45
- class WyreService {
46
- request = request;
47
- wyreGetKeys(req) {
48
- if (!config_1.default.wyre)
49
- throw new Error('Wyre missing credentials');
50
- let env = 'sandbox';
51
- if (req.body.env && req.body.env == 'production') {
52
- env = 'production';
53
- }
54
- delete req.body.env;
55
- const keys = {
56
- API: config_1.default.wyre[env].api,
57
- API_KEY: config_1.default.wyre[env].apiKey,
58
- SECRET_API_KEY: config_1.default.wyre[env].secretApiKey,
59
- ACCOUNT_ID: config_1.default.wyre[env].appProviderAccountId
60
- };
61
- return keys;
62
- }
63
- wyreWalletOrderQuotation(req) {
64
- return new Promise((resolve, reject) => {
65
- const keys = this.wyreGetKeys(req);
66
- req.body.accountId = keys.ACCOUNT_ID;
67
- if (req.body.amountIncludeFees) {
68
- if (!(0, server_1.checkRequired)(req.body, ['sourceAmount', 'sourceCurrency', 'destCurrency', 'dest', 'country', 'walletType'])) {
69
- return reject(new clienterror_1.ClientError("Wyre's request missing arguments"));
70
- }
71
- }
72
- else {
73
- if (!(0, server_1.checkRequired)(req.body, ['amount', 'sourceCurrency', 'destCurrency', 'dest', 'country'])) {
74
- return reject(new clienterror_1.ClientError("Wyre's request missing arguments"));
75
- }
76
- }
77
- const URL = `${keys.API}/v3/orders/quote/partner?timestamp=${Date.now().toString()}`;
78
- const XApiSignature = URL + JSON.stringify(req.body);
79
- const XApiSignatureHash = crypto_wallet_core_1.BitcoreLib.crypto.Hash.sha256hmac(Buffer.from(XApiSignature), Buffer.from(keys.SECRET_API_KEY)).toString('hex');
80
- const headers = {
81
- 'Content-Type': 'application/json',
82
- 'X-Api-Key': keys.API_KEY,
83
- 'X-Api-Signature': XApiSignatureHash
84
- };
85
- this.request.post(URL, {
86
- headers,
87
- body: req.body,
88
- json: true
89
- }, (err, data) => {
90
- if (err) {
91
- return reject(err.body ? err.body : err);
92
- }
93
- else {
94
- return resolve(data.body);
95
- }
96
- });
97
- });
98
- }
99
- wyreWalletOrderReservation(req) {
100
- return new Promise((resolve, reject) => {
101
- const keys = this.wyreGetKeys(req);
102
- req.body.referrerAccountId = keys.ACCOUNT_ID;
103
- if (req.body.amountIncludeFees) {
104
- if (!(0, server_1.checkRequired)(req.body, [
105
- 'sourceAmount',
106
- 'sourceCurrency',
107
- 'destCurrency',
108
- 'dest',
109
- 'country',
110
- 'paymentMethod'
111
- ])) {
112
- return reject(new clienterror_1.ClientError("Wyre's request missing arguments"));
113
- }
114
- }
115
- else {
116
- if (!(0, server_1.checkRequired)(req.body, ['amount', 'sourceCurrency', 'destCurrency', 'dest', 'paymentMethod'])) {
117
- return reject(new clienterror_1.ClientError("Wyre's request missing arguments"));
118
- }
119
- }
120
- const URL = `${keys.API}/v3/orders/reserve?timestamp=${Date.now().toString()}`;
121
- const XApiSignature = URL + JSON.stringify(req.body);
122
- const XApiSignatureHash = crypto_wallet_core_1.BitcoreLib.crypto.Hash.sha256hmac(Buffer.from(XApiSignature), Buffer.from(keys.SECRET_API_KEY)).toString('hex');
123
- const headers = {
124
- 'Content-Type': 'application/json',
125
- 'X-Api-Key': keys.API_KEY,
126
- 'X-Api-Signature': XApiSignatureHash
127
- };
128
- this.request.post(URL, {
129
- headers,
130
- body: req.body,
131
- json: true
132
- }, (err, data) => {
133
- if (err) {
134
- return reject(err.body ? err.body : err);
135
- }
136
- else {
137
- return resolve(data.body);
138
- }
139
- });
140
- });
141
- }
142
- }
143
- exports.WyreService = WyreService;
144
- //# sourceMappingURL=wyre.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wyre.js","sourceRoot":"","sources":["../../../src/externalservices/wyre.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wEAAwE;AACxE,iDAAmC;AACnC,uDAA+B;AAC/B,2DAAwD;AACxD,0CAA8C;AAE9C,MAAa,WAAW;IACtB,OAAO,GAAQ,OAAO,CAAC;IAEf,WAAW,CAAC,GAAG;QACrB,IAAI,CAAC,gBAAM,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAE9D,IAAI,GAAG,GAAG,SAAS,CAAC;QACpB,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,YAAY,EAAE,CAAC;YACjD,GAAG,GAAG,YAAY,CAAC;QACrB,CAAC;QACD,OAAO,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,EAAE;gBACZ,IAAI,GAAG,EAAE,CAAC;oBACR,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;gBAC3C,CAAC;qBAAM,CAAC;oBACN,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC5B,CAAC;YACH,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA5HD,kCA4HC"}
@@ -1,2 +0,0 @@
1
- import 'chai/register-should';
2
- //# sourceMappingURL=wyre.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wyre.test.d.ts","sourceRoot":"","sources":["../../../../test/integration/externalservices/wyre.test.ts"],"names":[],"mappings":"AAGA,OAAO,sBAAsB,CAAC"}