@spritz-finance/service-client 0.29.1 → 0.30.0
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/README.md +65 -0
- package/lib/bridge/bridgeServiceClient.js +8 -7
- package/lib/checkbook/checkbookServiceClient.js +5 -4
- package/lib/exchangeRates/exchangeRatesServiceClient.js +3 -2
- package/lib/features/featuresServiceClient.js +4 -3
- package/lib/growth/growthServiceClient.js +8 -7
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/liabilities/liabilitiesServiceClient.js +21 -20
- package/lib/notifications/notificationsServiceClient.js +3 -2
- package/lib/onramp/onrampServiceClient.js +6 -5
- package/lib/payableAccounts/payableAccountsServiceClient.js +16 -15
- package/lib/paymentAddress/paymentAddressServiceClient.js +3 -2
- package/lib/payments/paymentsClient.js +20 -19
- package/lib/payouts/payoutsServiceClient.js +8 -7
- package/lib/platform/platformServiceClient.js +11 -7
- package/lib/rain/rainServiceClient.js +15 -14
- package/lib/restClient.d.ts +2 -0
- package/lib/restClient.js +7 -0
- package/lib/serviceClient.d.ts +1 -1
- package/lib/serviceClient.js +8 -3
- package/lib/sigv4.d.ts +4 -0
- package/lib/sigv4.js +95 -0
- package/lib/transactions/transactionsServiceClient.js +8 -7
- package/lib/unblock/unblockServiceClient.js +8 -7
- package/lib/users/usersServiceClient.js +13 -12
- package/lib/verification/verificationServiceClient.js +9 -8
- package/lib/web3/web3ServiceClient.js +13 -12
- package/package.json +5 -1
package/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Service client
|
|
2
|
+
|
|
3
|
+
REST clients use the existing shared-secret credentials by default. To opt a client
|
|
4
|
+
into AWS IAM authentication, set its `<SVC>_SERVICE_API_IAM_URL` environment variable
|
|
5
|
+
**before importing this package**. No variable means the existing client, URLs,
|
|
6
|
+
headers, timeouts and retries are unchanged. Graph authentication is unaffected.
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
// Deployment environment:
|
|
10
|
+
// USERS_SERVICE_API_IAM_URL=https://example.lambda-url.us-east-1.on.aws
|
|
11
|
+
import { UsersClient } from "@spritz-finance/service-client";
|
|
12
|
+
|
|
13
|
+
await UsersClient.getUserById("user-id");
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Each namespace opts in independently, including namespaces that share a backend.
|
|
17
|
+
Set these variables to the corresponding service's IAM Function URL:
|
|
18
|
+
|
|
19
|
+
| Client | Environment variable |
|
|
20
|
+
| --------------------- | -------------------------------------- |
|
|
21
|
+
| BridgeClient | `BRIDGE_SERVICE_API_IAM_URL` |
|
|
22
|
+
| CheckbookClient | `CHECKBOOK_SERVICE_API_IAM_URL` |
|
|
23
|
+
| ExchangeRatesClient | `EXCHANGE_RATES_SERVICE_API_IAM_URL` |
|
|
24
|
+
| FeaturesClient | `FEATURES_SERVICE_API_IAM_URL` |
|
|
25
|
+
| GrowthClient | `GROWTH_SERVICE_API_IAM_URL` |
|
|
26
|
+
| LiabilitiesClient | `LIABILITIES_SERVICE_API_IAM_URL` |
|
|
27
|
+
| NotificationsClient | `NOTIFICATIONS_SERVICE_API_IAM_URL` |
|
|
28
|
+
| OnrampClient | `ONRAMP_SERVICE_API_IAM_URL` |
|
|
29
|
+
| PayableAccountsClient | `PAYABLE_ACCOUNTS_SERVICE_API_IAM_URL` |
|
|
30
|
+
| PaymentAddressClient | `PAYMENT_ADDRESS_SERVICE_API_IAM_URL` |
|
|
31
|
+
| PaymentsClient | `PAYMENTS_SERVICE_API_IAM_URL` |
|
|
32
|
+
| PayoutsClient | `PAYOUTS_SERVICE_API_IAM_URL` |
|
|
33
|
+
| PlatformClient | `PLATFORM_SERVICE_API_IAM_URL` |
|
|
34
|
+
| RainClient | `RAIN_SERVICE_API_IAM_URL` |
|
|
35
|
+
| TransactionsClient | `TRANSACTIONS_SERVICE_API_IAM_URL` |
|
|
36
|
+
| UnblockClient | `UNBLOCK_SERVICE_API_IAM_URL` |
|
|
37
|
+
| UsersClient | `USERS_SERVICE_API_IAM_URL` |
|
|
38
|
+
| VerificationClient | `VERIFICATION_SERVICE_API_IAM_URL` |
|
|
39
|
+
| Web3Client | `WEB3_SERVICE_API_IAM_URL` |
|
|
40
|
+
|
|
41
|
+
The IAM URL replaces the base URL; existing endpoint paths remain unchanged.
|
|
42
|
+
For example, UsersClient still requests `/v2/users/api/...`. The Function URL twin
|
|
43
|
+
must serve those paths. CheckbookClient and PaymentsClient target liabilities
|
|
44
|
+
routes; FeaturesClient targets users routes; BridgeClient and OnrampClient target
|
|
45
|
+
bridge routes. Their variables can point at the same backend URL.
|
|
46
|
+
|
|
47
|
+
The signer uses service `lambda` and the existing `config.region` (`REGION`, default
|
|
48
|
+
`us-east-1`). The Node SDK default credential chain resolves the caller's Lambda/ECS
|
|
49
|
+
role. The provider is reused; the SDK owns credential caching and refresh.
|
|
50
|
+
Signing itself adds no network round trips. Credential discovery/refresh may make
|
|
51
|
+
its normal SDK calls; there is no Secrets Manager/JWT authentication call in IAM mode.
|
|
52
|
+
|
|
53
|
+
IAM requests hash the serialized body, including custom axios transforms, and sign
|
|
54
|
+
the method, path, query, host and headers. JSON, strings, buffers, ArrayBuffers and
|
|
55
|
+
URLSearchParams are supported. Buffer streaming bodies before sending; unbuffered
|
|
56
|
+
streams are rejected. IAM requests do not follow redirects, because redirect hops
|
|
57
|
+
bypass request interceptors and could forward the session token. Existing timeouts
|
|
58
|
+
and 502 retry policies remain unchanged (Platform has no retry).
|
|
59
|
+
|
|
60
|
+
For an existing Node axios transport, the package also exports
|
|
61
|
+
`createSigV4Interceptor(iamUrl, credentialProvider?)`. Set axios's `baseURL` to the IAM
|
|
62
|
+
URL and register this interceptor **first** so it runs after other request
|
|
63
|
+
interceptors (axios runs them in reverse order). Both the request base URL and
|
|
64
|
+
resolved destination must match the configured IAM origin exactly. The optional
|
|
65
|
+
provider supports deterministic tests; production callers should use the default.
|
|
@@ -41,26 +41,27 @@ exports.validateTransfer = validateTransfer;
|
|
|
41
41
|
exports.createBridgeTransfer = createBridgeTransfer;
|
|
42
42
|
exports.getExternalPayments = getExternalPayments;
|
|
43
43
|
exports.BridgeClient = __importStar(require("./bridgeServiceClient"));
|
|
44
|
-
const
|
|
44
|
+
const restClient_1 = require("../restClient");
|
|
45
|
+
const baseClient = (0, restClient_1.getRestClient)(process.env.BRIDGE_SERVICE_API_IAM_URL);
|
|
45
46
|
const ONRAMP_ENDPOINT = "/bridge";
|
|
46
47
|
const ONRAMP_ROUTER_ENDPOINT = "/v2/bridge/api";
|
|
47
48
|
async function getTransferHashes(externalPaymentIds) {
|
|
48
|
-
return
|
|
49
|
+
return baseClient
|
|
49
50
|
.post(`${ONRAMP_ROUTER_ENDPOINT}/off-ramps/blockchain-transactions`, { externalPaymentIds })
|
|
50
51
|
.then((res) => res.data);
|
|
51
52
|
}
|
|
52
53
|
async function createBridgeBankAccount(userId, accountId, input) {
|
|
53
|
-
return
|
|
54
|
+
return baseClient
|
|
54
55
|
.post(`${ONRAMP_ENDPOINT}/user/${userId}/bank-account/${accountId}`, input)
|
|
55
56
|
.then((res) => res.data);
|
|
56
57
|
}
|
|
57
58
|
async function getBridgeUser(userId) {
|
|
58
|
-
return
|
|
59
|
+
return baseClient
|
|
59
60
|
.get(`${ONRAMP_ENDPOINT}/user/${userId}`)
|
|
60
61
|
.then((res) => res.data);
|
|
61
62
|
}
|
|
62
63
|
async function validateTransfer({ userId, transferId, amount, toAddress, }) {
|
|
63
|
-
return
|
|
64
|
+
return baseClient
|
|
64
65
|
.post(`${ONRAMP_ENDPOINT}/transfer/validate`, {
|
|
65
66
|
userId,
|
|
66
67
|
transferId,
|
|
@@ -70,12 +71,12 @@ async function validateTransfer({ userId, transferId, amount, toAddress, }) {
|
|
|
70
71
|
.then((res) => res.data);
|
|
71
72
|
}
|
|
72
73
|
async function createBridgeTransfer(userId, input) {
|
|
73
|
-
return
|
|
74
|
+
return baseClient
|
|
74
75
|
.post(`${ONRAMP_ROUTER_ENDPOINT}/off-ramps/users/${userId}/transfers`, input)
|
|
75
76
|
.then((res) => res.data);
|
|
76
77
|
}
|
|
77
78
|
async function getExternalPayments(paymentIds) {
|
|
78
|
-
return
|
|
79
|
+
return baseClient
|
|
79
80
|
.get(`${ONRAMP_ENDPOINT}/external-payments?paymentIds=${paymentIds.join(",")}`)
|
|
80
81
|
.then((res) => res.data);
|
|
81
82
|
}
|
|
@@ -38,10 +38,11 @@ exports.triggerBatch = triggerBatch;
|
|
|
38
38
|
exports.getBatchBalances = getBatchBalances;
|
|
39
39
|
exports.getFundingBatchBalances = getFundingBatchBalances;
|
|
40
40
|
exports.CheckbookClient = __importStar(require("./checkbookServiceClient"));
|
|
41
|
-
const
|
|
41
|
+
const restClient_1 = require("../restClient");
|
|
42
|
+
const baseClient = (0, restClient_1.getRestClient)(process.env.CHECKBOOK_SERVICE_API_IAM_URL);
|
|
42
43
|
const CHECKBOOK_ENDPOINT = "/liabilities";
|
|
43
44
|
async function triggerBatch({ config, configs, reserve, currency, }) {
|
|
44
|
-
return
|
|
45
|
+
return baseClient
|
|
45
46
|
.post(`${CHECKBOOK_ENDPOINT}/checkbook/batch`, {
|
|
46
47
|
config,
|
|
47
48
|
currency,
|
|
@@ -51,12 +52,12 @@ async function triggerBatch({ config, configs, reserve, currency, }) {
|
|
|
51
52
|
.then((res) => res.data);
|
|
52
53
|
}
|
|
53
54
|
async function getBatchBalances() {
|
|
54
|
-
return
|
|
55
|
+
return baseClient
|
|
55
56
|
.get(`${CHECKBOOK_ENDPOINT}/checkbook/batch/balances`)
|
|
56
57
|
.then((res) => res.data);
|
|
57
58
|
}
|
|
58
59
|
async function getFundingBatchBalances() {
|
|
59
|
-
return
|
|
60
|
+
return baseClient
|
|
60
61
|
.get(`${CHECKBOOK_ENDPOINT}/checkbook/batch/funding-balances`)
|
|
61
62
|
.then((res) => res.data);
|
|
62
63
|
}
|
|
@@ -36,10 +36,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.ExchangeRatesClient = void 0;
|
|
37
37
|
exports.getLatestRate = getLatestRate;
|
|
38
38
|
exports.ExchangeRatesClient = __importStar(require("./exchangeRatesServiceClient"));
|
|
39
|
-
const
|
|
39
|
+
const restClient_1 = require("../restClient");
|
|
40
|
+
const baseClient = (0, restClient_1.getRestClient)(process.env.EXCHANGE_RATES_SERVICE_API_IAM_URL);
|
|
40
41
|
const EXCHANGE_RATE_ENDPOINT = "/exchange-rates";
|
|
41
42
|
async function getLatestRate(target, base = "USD") {
|
|
42
|
-
return
|
|
43
|
+
return baseClient
|
|
43
44
|
.get(`${EXCHANGE_RATE_ENDPOINT}/latest`, {
|
|
44
45
|
params: {
|
|
45
46
|
target,
|
|
@@ -40,9 +40,10 @@ exports.isFeatureFlagEnabled = isFeatureFlagEnabled;
|
|
|
40
40
|
exports.isPaymentsEnabled = isPaymentsEnabled;
|
|
41
41
|
exports.isFeatureEnabled = isFeatureEnabled;
|
|
42
42
|
exports.FeaturesClient = __importStar(require("./featuresServiceClient"));
|
|
43
|
-
const
|
|
43
|
+
const restClient_1 = require("../restClient");
|
|
44
44
|
const utils_1 = require("../utils");
|
|
45
45
|
const types_1 = require("./types");
|
|
46
|
+
const baseClient = (0, restClient_1.getRestClient)(process.env.FEATURES_SERVICE_API_IAM_URL);
|
|
46
47
|
const FEATURES_ENDPOINT = "/v2/users/api/feature-flags";
|
|
47
48
|
const networkToFlag = (network) => {
|
|
48
49
|
switch (network) {
|
|
@@ -80,10 +81,10 @@ function updateFeatureFlag(input) {
|
|
|
80
81
|
...input,
|
|
81
82
|
source: (_a = input.source) !== null && _a !== void 0 ? _a : types_1.FlagSource.Automatic,
|
|
82
83
|
};
|
|
83
|
-
return
|
|
84
|
+
return baseClient.post(FEATURES_ENDPOINT, payload);
|
|
84
85
|
}
|
|
85
86
|
async function getFeatureFlags() {
|
|
86
|
-
return
|
|
87
|
+
return baseClient.get(FEATURES_ENDPOINT).then((res) => res.data);
|
|
87
88
|
}
|
|
88
89
|
async function isFeatureFlagEnabled(flag) {
|
|
89
90
|
var _a, _b;
|
|
@@ -41,7 +41,8 @@ exports.getPointsRedemptionOption = getPointsRedemptionOption;
|
|
|
41
41
|
exports.validatePointsRedemption = validatePointsRedemption;
|
|
42
42
|
exports.confirmPointsRedemption = confirmPointsRedemption;
|
|
43
43
|
exports.GrowthClient = __importStar(require("./growthServiceClient"));
|
|
44
|
-
const
|
|
44
|
+
const restClient_1 = require("../restClient");
|
|
45
|
+
const baseClient = (0, restClient_1.getRestClient)(process.env.GROWTH_SERVICE_API_IAM_URL);
|
|
45
46
|
const GROWTH_ENDPOINT = "/growth";
|
|
46
47
|
const GROWTH_SERVICE_API_ENDPOINT = "/v2/growth/api";
|
|
47
48
|
/**
|
|
@@ -49,7 +50,7 @@ const GROWTH_SERVICE_API_ENDPOINT = "/v2/growth/api";
|
|
|
49
50
|
* accounts. Use `getUserReferrerAccount` and resolve the referrer by `userId`.
|
|
50
51
|
*/
|
|
51
52
|
async function getUserReferrer(userId) {
|
|
52
|
-
return
|
|
53
|
+
return baseClient
|
|
53
54
|
.get(`${GROWTH_ENDPOINT}/referrals/referrer/${userId}`)
|
|
54
55
|
.then((res) => res.data);
|
|
55
56
|
}
|
|
@@ -58,27 +59,27 @@ async function getUserReferrer(userId) {
|
|
|
58
59
|
* row or was not referred.
|
|
59
60
|
*/
|
|
60
61
|
async function getUserReferrerAccount(userId) {
|
|
61
|
-
return
|
|
62
|
+
return baseClient
|
|
62
63
|
.get(`${GROWTH_SERVICE_API_ENDPOINT}/referrals/${encodeURIComponent(userId)}/referrer`)
|
|
63
64
|
.then((res) => res.data);
|
|
64
65
|
}
|
|
65
66
|
async function initializePointsRedemption(input) {
|
|
66
|
-
return
|
|
67
|
+
return baseClient
|
|
67
68
|
.post(`${GROWTH_ENDPOINT}/v2/points/redemption/initialize`, input)
|
|
68
69
|
.then((res) => res.data);
|
|
69
70
|
}
|
|
70
71
|
async function getPointsRedemptionOption(input) {
|
|
71
|
-
return
|
|
72
|
+
return baseClient
|
|
72
73
|
.post(`${GROWTH_ENDPOINT}/v2/points/redemption/option`, input)
|
|
73
74
|
.then((res) => res.data);
|
|
74
75
|
}
|
|
75
76
|
async function validatePointsRedemption(input) {
|
|
76
|
-
return
|
|
77
|
+
return baseClient
|
|
77
78
|
.post(`${GROWTH_ENDPOINT}/v2/points/redemption/validate`, input)
|
|
78
79
|
.then((res) => res.data);
|
|
79
80
|
}
|
|
80
81
|
async function confirmPointsRedemption(input) {
|
|
81
|
-
return
|
|
82
|
+
return baseClient
|
|
82
83
|
.post(`${GROWTH_ENDPOINT}/v2/points/redemption/confirm`, input)
|
|
83
84
|
.then((res) => res.data);
|
|
84
85
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export { UnblockClient } from "./unblock/unblockServiceClient";
|
|
|
35
35
|
export * from "./users/types";
|
|
36
36
|
export { UsersClient } from "./users/usersServiceClient";
|
|
37
37
|
export * from "./utils";
|
|
38
|
+
export { createSigV4Interceptor } from "./sigv4";
|
|
38
39
|
export * from "./verification/types";
|
|
39
40
|
export { VerificationClient } from "./verification/verificationServiceClient";
|
|
40
41
|
export * from "./web3/types";
|
package/lib/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Web3Client = exports.VerificationClient = exports.UsersClient = exports.UnblockClient = exports.TransactionsClient = exports.RainClient = exports.PayoutsClient = exports.PaymentsClient = exports.PlatformClient = exports.PaymentAddressClient = exports.PayableAccountsClient = exports.OnrampClient = exports.NotificationsClient = exports.LiabilitiesClient = exports.GrowthClient = exports.FeaturesClient = exports.ExchangeRatesClient = exports.CheckbookClient = exports.BridgeClient = void 0;
|
|
17
|
+
exports.Web3Client = exports.VerificationClient = exports.createSigV4Interceptor = exports.UsersClient = exports.UnblockClient = exports.TransactionsClient = exports.RainClient = exports.PayoutsClient = exports.PaymentsClient = exports.PlatformClient = exports.PaymentAddressClient = exports.PayableAccountsClient = exports.OnrampClient = exports.NotificationsClient = exports.LiabilitiesClient = exports.GrowthClient = exports.FeaturesClient = exports.ExchangeRatesClient = exports.CheckbookClient = exports.BridgeClient = void 0;
|
|
18
18
|
var bridgeServiceClient_1 = require("./bridge/bridgeServiceClient");
|
|
19
19
|
Object.defineProperty(exports, "BridgeClient", { enumerable: true, get: function () { return bridgeServiceClient_1.BridgeClient; } });
|
|
20
20
|
__exportStar(require("./bridge/types"), exports);
|
|
@@ -69,6 +69,8 @@ __exportStar(require("./users/types"), exports);
|
|
|
69
69
|
var usersServiceClient_1 = require("./users/usersServiceClient");
|
|
70
70
|
Object.defineProperty(exports, "UsersClient", { enumerable: true, get: function () { return usersServiceClient_1.UsersClient; } });
|
|
71
71
|
__exportStar(require("./utils"), exports);
|
|
72
|
+
var sigv4_1 = require("./sigv4");
|
|
73
|
+
Object.defineProperty(exports, "createSigV4Interceptor", { enumerable: true, get: function () { return sigv4_1.createSigV4Interceptor; } });
|
|
72
74
|
__exportStar(require("./verification/types"), exports);
|
|
73
75
|
var verificationServiceClient_1 = require("./verification/verificationServiceClient");
|
|
74
76
|
Object.defineProperty(exports, "VerificationClient", { enumerable: true, get: function () { return verificationServiceClient_1.VerificationClient; } });
|
|
@@ -54,45 +54,46 @@ exports.getRewardTransactionsFor = getRewardTransactionsFor;
|
|
|
54
54
|
exports.getDirectPayment = getDirectPayment;
|
|
55
55
|
exports.issueRefundCredit = issueRefundCredit;
|
|
56
56
|
exports.LiabilitiesClient = __importStar(require("./liabilitiesServiceClient"));
|
|
57
|
-
const
|
|
57
|
+
const restClient_1 = require("../restClient");
|
|
58
|
+
const baseClient = (0, restClient_1.getRestClient)(process.env.LIABILITIES_SERVICE_API_IAM_URL);
|
|
58
59
|
const LIABILITIES_ENDPOINT = "/liabilities";
|
|
59
60
|
async function getRewardTransaction(transactionId) {
|
|
60
|
-
return
|
|
61
|
+
return baseClient
|
|
61
62
|
.get(`${LIABILITIES_ENDPOINT}/reward-transactions/${transactionId}`)
|
|
62
63
|
.then((res) => res.data);
|
|
63
64
|
}
|
|
64
65
|
async function createMethodFiEntity(args) {
|
|
65
|
-
return
|
|
66
|
+
return baseClient
|
|
66
67
|
.post(`${LIABILITIES_ENDPOINT}/methodFi/entity2`, args)
|
|
67
68
|
.then((res) => res.data);
|
|
68
69
|
}
|
|
69
70
|
async function getMethodFiEntity(userId) {
|
|
70
|
-
return
|
|
71
|
+
return baseClient
|
|
71
72
|
.get(`${LIABILITIES_ENDPOINT}/methodFi/entity/user/${userId}`)
|
|
72
73
|
.then((res) => res.data);
|
|
73
74
|
}
|
|
74
75
|
async function createCheckbookUser(args) {
|
|
75
|
-
return
|
|
76
|
+
return baseClient
|
|
76
77
|
.post(`${LIABILITIES_ENDPOINT}/checkbook/user`, args)
|
|
77
78
|
.then((res) => res.data);
|
|
78
79
|
}
|
|
79
80
|
async function upsertCheckbookUser(args) {
|
|
80
|
-
return
|
|
81
|
+
return baseClient
|
|
81
82
|
.post(`${LIABILITIES_ENDPOINT}/checkbook/user/upsert`, args)
|
|
82
83
|
.then((res) => res.data);
|
|
83
84
|
}
|
|
84
85
|
async function getCheckbookUser(userId) {
|
|
85
|
-
return
|
|
86
|
+
return baseClient
|
|
86
87
|
.get(`${LIABILITIES_ENDPOINT}/checkbook/user/${userId}`)
|
|
87
88
|
.then((res) => res.data);
|
|
88
89
|
}
|
|
89
90
|
async function createCheckbookVirtualCard(userId) {
|
|
90
|
-
return
|
|
91
|
+
return baseClient
|
|
91
92
|
.post(`${LIABILITIES_ENDPOINT}/virtual-card/create/${userId}`)
|
|
92
93
|
.then((res) => res.data);
|
|
93
94
|
}
|
|
94
95
|
async function createCheckbookDebitCard(input) {
|
|
95
|
-
return
|
|
96
|
+
return baseClient
|
|
96
97
|
.post(`${LIABILITIES_ENDPOINT}/debit-card/create`, input)
|
|
97
98
|
.then((res) => res.data);
|
|
98
99
|
}
|
|
@@ -109,7 +110,7 @@ async function createTokenizedDebitCard(input) {
|
|
|
109
110
|
// standard `{ status, data }` envelope. Unwrap it here so callers keep the
|
|
110
111
|
// simple `{ externalId, cardLast4 }` contract; surface the provider error
|
|
111
112
|
// message on failure instead of an opaque error.
|
|
112
|
-
const res = await
|
|
113
|
+
const res = await baseClient.post(`${LIABILITIES_V2_ENDPOINT}/checkbook/debit-card/create`, input);
|
|
113
114
|
const body = res.data;
|
|
114
115
|
if (body.status === "failure") {
|
|
115
116
|
throw new Error((_b = (_a = body.error) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : "Tokenized debit card creation failed");
|
|
@@ -120,12 +121,12 @@ async function createTokenizedDebitCard(input) {
|
|
|
120
121
|
};
|
|
121
122
|
}
|
|
122
123
|
async function createCheckbookDigitalAccount(input) {
|
|
123
|
-
return
|
|
124
|
+
return baseClient
|
|
124
125
|
.post(`${LIABILITIES_ENDPOINT}/digital-account/create`, input)
|
|
125
126
|
.then((res) => res.data);
|
|
126
127
|
}
|
|
127
128
|
async function createUSBillFromAccountNumber(userId, accountNumber, merchantId) {
|
|
128
|
-
return
|
|
129
|
+
return baseClient
|
|
129
130
|
.post(`${LIABILITIES_ENDPOINT}/methodFi/bill/user/${userId}`, {
|
|
130
131
|
accountNumber,
|
|
131
132
|
merchantId,
|
|
@@ -133,17 +134,17 @@ async function createUSBillFromAccountNumber(userId, accountNumber, merchantId)
|
|
|
133
134
|
.then((res) => res.data);
|
|
134
135
|
}
|
|
135
136
|
async function getVirtualCardBalance(cardExternalId, userId) {
|
|
136
|
-
return
|
|
137
|
+
return baseClient
|
|
137
138
|
.get(`${LIABILITIES_ENDPOINT}/virtual-card/card/${cardExternalId}/balance?userId=${userId}`)
|
|
138
139
|
.then((res) => res.data);
|
|
139
140
|
}
|
|
140
141
|
async function getUserIdForDirectPayment(directPaymentId) {
|
|
141
|
-
return
|
|
142
|
+
return baseClient
|
|
142
143
|
.get(`${LIABILITIES_ENDPOINT}/direct-payments/${directPaymentId}/user`)
|
|
143
144
|
.then((res) => res.data);
|
|
144
145
|
}
|
|
145
146
|
async function updateCheckbookVirtualCard(userId, cardExternalId) {
|
|
146
|
-
return
|
|
147
|
+
return baseClient
|
|
147
148
|
.post(`${LIABILITIES_ENDPOINT}/virtual-card/update`, {
|
|
148
149
|
userId,
|
|
149
150
|
cardExternalId,
|
|
@@ -151,28 +152,28 @@ async function updateCheckbookVirtualCard(userId, cardExternalId) {
|
|
|
151
152
|
.then((res) => res.data);
|
|
152
153
|
}
|
|
153
154
|
async function addPromotionCredit(input) {
|
|
154
|
-
return
|
|
155
|
+
return baseClient
|
|
155
156
|
.post(`${LIABILITIES_ENDPOINT}/rewards/promotion`, input)
|
|
156
157
|
.then((res) => res.data);
|
|
157
158
|
}
|
|
158
159
|
async function addCashbackCredit(input) {
|
|
159
|
-
return
|
|
160
|
+
return baseClient
|
|
160
161
|
.post(`${LIABILITIES_ENDPOINT}/rewards/cashback`, input)
|
|
161
162
|
.then((res) => res.data);
|
|
162
163
|
}
|
|
163
164
|
async function getRewardTransactionsFor(userId) {
|
|
164
|
-
return
|
|
165
|
+
return baseClient
|
|
165
166
|
.get(`${LIABILITIES_ENDPOINT}/rewards/user/${userId}/transactions`)
|
|
166
167
|
.then((res) => res.data);
|
|
167
168
|
}
|
|
168
169
|
const LIABILITIES_V2_ENDPOINT = "/v2/liabilities/api";
|
|
169
170
|
async function getDirectPayment(directPaymentId) {
|
|
170
|
-
return
|
|
171
|
+
return baseClient
|
|
171
172
|
.get(`${LIABILITIES_V2_ENDPOINT}/direct-payment/${directPaymentId}`)
|
|
172
173
|
.then((res) => res.data);
|
|
173
174
|
}
|
|
174
175
|
async function issueRefundCredit(userId, input) {
|
|
175
|
-
return
|
|
176
|
+
return baseClient
|
|
176
177
|
.post(`${LIABILITIES_V2_ENDPOINT}/rewards/users/${userId}/refund-credits`, input)
|
|
177
178
|
.then((res) => res.data);
|
|
178
179
|
}
|
|
@@ -36,7 +36,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.NotificationsClient = void 0;
|
|
37
37
|
exports.verifyEmail = verifyEmail;
|
|
38
38
|
exports.NotificationsClient = __importStar(require("./notificationsServiceClient"));
|
|
39
|
-
const
|
|
39
|
+
const restClient_1 = require("../restClient");
|
|
40
|
+
const baseClient = (0, restClient_1.getRestClient)(process.env.NOTIFICATIONS_SERVICE_API_IAM_URL);
|
|
40
41
|
const NOTIFICATIONS_ENDPOINT = "/v2/notifications/api";
|
|
41
42
|
/**
|
|
42
43
|
* Verifies deliverability through the notifications service's reputation
|
|
@@ -45,7 +46,7 @@ const NOTIFICATIONS_ENDPOINT = "/v2/notifications/api";
|
|
|
45
46
|
* treat an ApiFailure as accept rather than block on retries.
|
|
46
47
|
*/
|
|
47
48
|
async function verifyEmail(email) {
|
|
48
|
-
return
|
|
49
|
+
return baseClient
|
|
49
50
|
.post(`${NOTIFICATIONS_ENDPOINT}/email-verification`, {
|
|
50
51
|
email,
|
|
51
52
|
})
|
|
@@ -39,25 +39,26 @@ exports.getUserCompletedPayments = getUserCompletedPayments;
|
|
|
39
39
|
exports.upsertBridgeUser = upsertBridgeUser;
|
|
40
40
|
exports.createBusinessUser = createBusinessUser;
|
|
41
41
|
exports.OnrampClient = __importStar(require("./onrampServiceClient"));
|
|
42
|
-
const
|
|
42
|
+
const restClient_1 = require("../restClient");
|
|
43
|
+
const baseClient = (0, restClient_1.getRestClient)(process.env.ONRAMP_SERVICE_API_IAM_URL);
|
|
43
44
|
const ONRAMP_ENDPOINT = "/bridge";
|
|
44
45
|
async function syncTransfer(input) {
|
|
45
|
-
return
|
|
46
|
+
return baseClient
|
|
46
47
|
.post(`${ONRAMP_ENDPOINT}/external-transfer`, input)
|
|
47
48
|
.then((res) => res.data);
|
|
48
49
|
}
|
|
49
50
|
async function getUserCompletedPayments(userId) {
|
|
50
|
-
return
|
|
51
|
+
return baseClient
|
|
51
52
|
.get(`${ONRAMP_ENDPOINT}/payments/user/${userId}/completed`)
|
|
52
53
|
.then((res) => res.data);
|
|
53
54
|
}
|
|
54
55
|
async function upsertBridgeUser(input) {
|
|
55
|
-
return
|
|
56
|
+
return baseClient
|
|
56
57
|
.post(`${ONRAMP_ENDPOINT}/user`, input)
|
|
57
58
|
.then((res) => res.data);
|
|
58
59
|
}
|
|
59
60
|
async function createBusinessUser(userId, businessName) {
|
|
60
|
-
return
|
|
61
|
+
return baseClient
|
|
61
62
|
.post(`${ONRAMP_ENDPOINT}/business-user`, {
|
|
62
63
|
userId,
|
|
63
64
|
businessName,
|
|
@@ -49,58 +49,59 @@ exports.disablePayoutRail = disablePayoutRail;
|
|
|
49
49
|
exports.markUnpayable = markUnpayable;
|
|
50
50
|
exports.markDebitCardUnpayable = markDebitCardUnpayable;
|
|
51
51
|
exports.PayableAccountsClient = __importStar(require("./payableAccountsServiceClient"));
|
|
52
|
-
const
|
|
52
|
+
const restClient_1 = require("../restClient");
|
|
53
|
+
const baseClient = (0, restClient_1.getRestClient)(process.env.PAYABLE_ACCOUNTS_SERVICE_API_IAM_URL);
|
|
53
54
|
const PAYABLE_ACCOUNTS_ENDPOINT = "/payable-accounts";
|
|
54
55
|
// The Hono ServiceApi (`/api/{proxy+}`) is mapped on the shared gateway domain
|
|
55
56
|
// under the `payable-accounts-v2` key (serverless.yaml HTTPAPIMapping).
|
|
56
57
|
const PAYABLE_ACCOUNTS_ROUTER_ENDPOINT = "/payable-accounts-v2/api";
|
|
57
58
|
async function getAccount(accountId) {
|
|
58
|
-
return
|
|
59
|
+
return baseClient
|
|
59
60
|
.get(`${PAYABLE_ACCOUNTS_ENDPOINT}/payable-account/id/${accountId}`)
|
|
60
61
|
.then((res) => res.data);
|
|
61
62
|
}
|
|
62
63
|
async function getAccountByExternalId(externalId) {
|
|
63
|
-
return
|
|
64
|
+
return baseClient
|
|
64
65
|
.get(`${PAYABLE_ACCOUNTS_ENDPOINT}/payable-account/externalId/${externalId}`)
|
|
65
66
|
.then((res) => res.data);
|
|
66
67
|
}
|
|
67
68
|
async function getAccountsForUser(userId) {
|
|
68
|
-
return
|
|
69
|
+
return baseClient
|
|
69
70
|
.get(`${PAYABLE_ACCOUNTS_ENDPOINT}/payable-accounts/user/${userId}`)
|
|
70
71
|
.then((res) => res.data);
|
|
71
72
|
}
|
|
72
73
|
async function getAccounts(accountIds) {
|
|
73
|
-
return
|
|
74
|
+
return baseClient
|
|
74
75
|
.get(`${PAYABLE_ACCOUNTS_ENDPOINT}/payable-accounts?accountIds=${accountIds.join(",")}`)
|
|
75
76
|
.then((res) => res.data);
|
|
76
77
|
}
|
|
77
78
|
async function getAccountInstitution(institutionId) {
|
|
78
|
-
return
|
|
79
|
+
return baseClient
|
|
79
80
|
.get(`${PAYABLE_ACCOUNTS_ENDPOINT}/account-institution/id/${institutionId}`)
|
|
80
81
|
.then((res) => res.data);
|
|
81
82
|
}
|
|
82
83
|
async function upsertBillFromExternalAccount(input) {
|
|
83
|
-
return
|
|
84
|
+
return baseClient
|
|
84
85
|
.post(`${PAYABLE_ACCOUNTS_ENDPOINT}/bills/upsert-external-account`, input)
|
|
85
86
|
.then((res) => res.data);
|
|
86
87
|
}
|
|
87
88
|
async function getAccountById(accountId) {
|
|
88
|
-
return
|
|
89
|
+
return baseClient
|
|
89
90
|
.get(`${PAYABLE_ACCOUNTS_ENDPOINT}/v2/payable-account/id/${accountId}`)
|
|
90
91
|
.then((res) => res.data);
|
|
91
92
|
}
|
|
92
93
|
async function createUSVirtualCardNoKyc(userId) {
|
|
93
|
-
return
|
|
94
|
+
return baseClient
|
|
94
95
|
.post(`${PAYABLE_ACCOUNTS_ENDPOINT}/v2/virtual-card/create-no-kyc/${userId}`)
|
|
95
96
|
.then((res) => res.data);
|
|
96
97
|
}
|
|
97
98
|
async function upsertVirtualCard(input) {
|
|
98
|
-
return
|
|
99
|
+
return baseClient
|
|
99
100
|
.post(`${PAYABLE_ACCOUNTS_ENDPOINT}/virtual-card/upsert-external-card`, input)
|
|
100
101
|
.then((res) => res.data);
|
|
101
102
|
}
|
|
102
103
|
async function getRecentCardSpendTransactions(userId) {
|
|
103
|
-
return
|
|
104
|
+
return baseClient
|
|
104
105
|
.get(`${PAYABLE_ACCOUNTS_ENDPOINT}/virtual-card/recent-transactions/user/${userId}`)
|
|
105
106
|
.then((res) => res.data);
|
|
106
107
|
}
|
|
@@ -111,7 +112,7 @@ async function getRecentCardSpendTransactions(userId) {
|
|
|
111
112
|
* cannot expose.
|
|
112
113
|
*/
|
|
113
114
|
async function getDebitCardById(userId, cardId) {
|
|
114
|
-
return
|
|
115
|
+
return baseClient
|
|
115
116
|
.get(`${PAYABLE_ACCOUNTS_ROUTER_ENDPOINT}/debit-cards/${cardId}/user/${userId}`)
|
|
116
117
|
.then((res) => res.data);
|
|
117
118
|
}
|
|
@@ -124,7 +125,7 @@ async function getDebitCardById(userId, cardId) {
|
|
|
124
125
|
* the other rails enabled lets a reissue downgrade onto a doomed rail.
|
|
125
126
|
*/
|
|
126
127
|
async function disablePayoutRail(accountId, rail, reason) {
|
|
127
|
-
return
|
|
128
|
+
return baseClient
|
|
128
129
|
.post(`${PAYABLE_ACCOUNTS_ROUTER_ENDPOINT}/bank-accounts/${accountId}/payout-rails/disable`, { rail, reason })
|
|
129
130
|
.then((res) => res.data);
|
|
130
131
|
}
|
|
@@ -134,7 +135,7 @@ async function disablePayoutRail(accountId, rail, reason) {
|
|
|
134
135
|
* ACH R02/R03/R04 — so no retry, reissue or downgrade can reach it. Idempotent.
|
|
135
136
|
*/
|
|
136
137
|
async function markUnpayable(accountId, code, reason) {
|
|
137
|
-
return
|
|
138
|
+
return baseClient
|
|
138
139
|
.post(`${PAYABLE_ACCOUNTS_ROUTER_ENDPOINT}/bank-accounts/${accountId}/unpayable`, { code, reason })
|
|
139
140
|
.then((res) => res.data);
|
|
140
141
|
}
|
|
@@ -144,7 +145,7 @@ async function markUnpayable(accountId, code, reason) {
|
|
|
144
145
|
* and redirect on; the user must add a replacement card. Idempotent.
|
|
145
146
|
*/
|
|
146
147
|
async function markDebitCardUnpayable(cardId, code, reason) {
|
|
147
|
-
return
|
|
148
|
+
return baseClient
|
|
148
149
|
.post(`${PAYABLE_ACCOUNTS_ROUTER_ENDPOINT}/debit-cards/${cardId}/unpayable`, { code, reason })
|
|
149
150
|
.then((res) => res.data);
|
|
150
151
|
}
|
|
@@ -36,10 +36,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.PaymentAddressClient = void 0;
|
|
37
37
|
exports.initializePaymentAddresses = initializePaymentAddresses;
|
|
38
38
|
exports.PaymentAddressClient = __importStar(require("./paymentAddressServiceClient"));
|
|
39
|
-
const
|
|
39
|
+
const restClient_1 = require("../restClient");
|
|
40
|
+
const baseClient = (0, restClient_1.getRestClient)(process.env.PAYMENT_ADDRESS_SERVICE_API_IAM_URL);
|
|
40
41
|
const PAYABLE_ACCOUNTS_ENDPOINT = "/payment-addresses";
|
|
41
42
|
async function initializePaymentAddresses(body) {
|
|
42
|
-
return
|
|
43
|
+
return baseClient
|
|
43
44
|
.post(`${PAYABLE_ACCOUNTS_ENDPOINT}/payment-addresses/initialize`, body)
|
|
44
45
|
.then((res) => res.data);
|
|
45
46
|
}
|