@owneraio/finp2p-sdk-js 0.29.12 → 0.29.13
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.
- package/lib/types/Payments/Payments.d.ts +2 -2
- package/lib/validators/__tests__/validateWithdrawRequest.test.d.ts +1 -0
- package/lib/validators/__tests__/validateWithdrawRequest.test.js +30 -0
- package/lib/validators/__tests__/validateWithdrawRequest.test.js.map +1 -0
- package/lib/validators/validateWithdrawRequest.js +2 -24
- package/lib/validators/validateWithdrawRequest.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Operation, RequestOptions } from '../Commons';
|
|
2
2
|
import { FinP2PAsset, ManualSignaturePolicy } from '../Profiles';
|
|
3
|
-
import {
|
|
3
|
+
import { FinIdAccount } from '../Profiles/Accounts';
|
|
4
4
|
import { Iso4217Code } from '../utils';
|
|
5
5
|
export type PayoutAccountType = 'IBAN' | 'usAccount' | 'cryptocurrency';
|
|
6
6
|
export type PayoutAccountStatus = 'active' | 'non_active';
|
|
@@ -110,6 +110,6 @@ export type DepositAccount = {
|
|
|
110
110
|
};
|
|
111
111
|
export type WithdrawAccount = {
|
|
112
112
|
asset: FinP2PAsset;
|
|
113
|
-
account: FinIdAccount
|
|
113
|
+
account: FinIdAccount;
|
|
114
114
|
};
|
|
115
115
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const validateWithdrawRequest_1 = __importDefault(require("../validateWithdrawRequest"));
|
|
7
|
+
const asset = { assetIdentifierType: 'finp2p', resourceId: 'org:102:usd' };
|
|
8
|
+
const finIdAccount = (finId) => ({ type: 'finId', finId, orgId: 'org', custodian: { orgId: 'org' } });
|
|
9
|
+
const request = (account) => ({
|
|
10
|
+
userId: 'org:101:user',
|
|
11
|
+
amount: '10',
|
|
12
|
+
account: { asset, account: finIdAccount('fin-1') },
|
|
13
|
+
withdrawInstruction: { description: 'to my wallet', account: { asset, account } },
|
|
14
|
+
});
|
|
15
|
+
describe('validateWithdrawRequest (#1436)', () => {
|
|
16
|
+
it('accepts a finId destination', () => {
|
|
17
|
+
expect((0, validateWithdrawRequest_1.default)(request(finIdAccount('fin-2')))).toBe(true);
|
|
18
|
+
});
|
|
19
|
+
it.each([
|
|
20
|
+
['iban', { type: 'iban', code: 'GB33BUKB20201555555555' }],
|
|
21
|
+
['cryptoWallet', { type: 'cryptoWallet', address: '0xabc' }],
|
|
22
|
+
])('rejects a %s destination, which the router does not take, naming finId as the only type', (_type, account) => {
|
|
23
|
+
expect(() => (0, validateWithdrawRequest_1.default)(request(account))).toThrow(expect.objectContaining({
|
|
24
|
+
name: 'WithdrawRequestError',
|
|
25
|
+
code: 400,
|
|
26
|
+
detail: expect.stringMatching(/'withdrawInstruction\.account\.type' .* is a 'finId'$/),
|
|
27
|
+
}));
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=validateWithdrawRequest.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateWithdrawRequest.test.js","sourceRoot":"","sources":["../../../src/validators/__tests__/validateWithdrawRequest.test.ts"],"names":[],"mappings":";;;;;AAAA,yFAAiE;AAEjE,MAAM,KAAK,GAAG,EAAE,mBAAmB,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;AAC3E,MAAM,YAAY,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;AAC9G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ports, "__esModule", { value: true });
|
|
6
6
|
const ts_pattern_1 = require("ts-pattern");
|
|
7
|
-
const types_1 = require("../types");
|
|
8
7
|
const utils_1 = require("./utils");
|
|
9
8
|
const validateDepositRequest_1 = __importDefault(require("./validateDepositRequest"));
|
|
10
9
|
const name = 'WithdrawRequestError';
|
|
@@ -45,38 +44,17 @@ const validateWithdrawRequest = (req) => {
|
|
|
45
44
|
name,
|
|
46
45
|
});
|
|
47
46
|
}
|
|
48
|
-
if (
|
|
47
|
+
if (withdrawAccount.account.type !== 'finId') {
|
|
49
48
|
(0, utils_1.throwError)({
|
|
50
49
|
data: {
|
|
51
50
|
withdrawInstruction,
|
|
52
51
|
},
|
|
53
|
-
detail: (0, utils_1.getErrorDetail)({ path: 'withdrawInstruction.account.type', type: 'finId
|
|
52
|
+
detail: (0, utils_1.getErrorDetail)({ path: 'withdrawInstruction.account.type', type: 'finId' }),
|
|
54
53
|
message,
|
|
55
54
|
name,
|
|
56
55
|
});
|
|
57
56
|
}
|
|
58
57
|
(0, ts_pattern_1.match)(withdrawAccount)
|
|
59
|
-
.with({
|
|
60
|
-
asset: {
|
|
61
|
-
assetIdentifierType: types_1.assetFinP2PType,
|
|
62
|
-
resourceId: ts_pattern_1.P.select('resourceId'),
|
|
63
|
-
},
|
|
64
|
-
account: {
|
|
65
|
-
type: 'iban',
|
|
66
|
-
},
|
|
67
|
-
}, (selected) => {
|
|
68
|
-
const { resourceId } = selected !== null && selected !== void 0 ? selected : {};
|
|
69
|
-
if (typeof resourceId !== 'string' || !resourceId) {
|
|
70
|
-
(0, utils_1.throwError)({
|
|
71
|
-
data: {
|
|
72
|
-
resourceId,
|
|
73
|
-
},
|
|
74
|
-
detail: (0, utils_1.getErrorDetail)({ path: 'withdrawInstruction.account.asset.resourceId' }),
|
|
75
|
-
message,
|
|
76
|
-
name,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
})
|
|
80
58
|
.with({
|
|
81
59
|
asset: {
|
|
82
60
|
resourceId: ts_pattern_1.P.select('resourceId'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateWithdrawRequest.js","sourceRoot":"","sources":["../../src/validators/validateWithdrawRequest.ts"],"names":[],"mappings":";;;;;AAAA,2CAAsC;
|
|
1
|
+
{"version":3,"file":"validateWithdrawRequest.js","sourceRoot":"","sources":["../../src/validators/validateWithdrawRequest.ts"],"names":[],"mappings":";;;;;AAAA,2CAAsC;AAEtC,mCAAqD;AACrD,sFAA8D;AAE9D,MAAM,IAAI,GAAG,sBAAsB,CAAC;AACpC,MAAM,OAAO,GAAG,mCAAmC,CAAC;AAEpD,MAAM,uBAAuB,GAAG,CAAC,GAKhC,EAAW,EAAE;IACZ,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,EAAE,GAAG,GAAG,CAAC;IAE7D,IAAA,gCAAsB,EAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IAEpD,IACE,OAAO,mBAAmB,KAAK,QAAQ;QACvC,CAAC,mBAAmB;QACpB,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,MAAM,KAAK,CAAC,EAC7C,CAAC;QACD,IAAA,kBAAU,EAAC;YACT,IAAI,EAAE;gBACJ,mBAAmB;aACpB;YACD,MAAM,EAAE,IAAA,sBAAc,EAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;YACvE,OAAO,EAAE,4EAA4E;YACrF,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAED,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,mBAAmB,CAAC;IACtE,IAAI,OAAO,WAAW,KAAK,QAAQ,IAAI,CAAC,WAAW,EAAE,CAAC;QACpD,IAAA,kBAAU,EAAC;YACT,IAAI,EAAE;gBACJ,mBAAmB;aACpB;YACD,MAAM,EAAE,IAAA,sBAAc,EAAC,EAAE,IAAI,EAA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