@spritz-finance/service-client 0.29.1 → 0.31.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 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.
@@ -1,7 +1,7 @@
1
1
  export * as BridgeClient from "./bridgeServiceClient";
2
2
  import { ExternalPayment } from "../lib/graphClient/generated";
3
3
  import { BridgeUser } from "../onramp/types";
4
- import { BridgeExternalAccount, BridgeNetwork, BridgeTransfer, BridgeTransferOffRampPaymentRail, CreateBridgeAccountParams } from "./types";
4
+ import { BridgeCurrency, BridgeExchangeRates, BridgeExternalAccount, BridgeNetwork, BridgeTransfer, BridgeTransferOffRampPaymentRail, CreateBridgeAccountParams } from "./types";
5
5
  export declare function getTransferHashes(externalPaymentIds: string[]): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<{
6
6
  externalPaymentId: string;
7
7
  hash: string | null;
@@ -23,4 +23,5 @@ export declare function createBridgeTransfer(userId: string, input: {
23
23
  accountId: string;
24
24
  paymentRail: BridgeTransferOffRampPaymentRail;
25
25
  }): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<BridgeTransfer>>;
26
+ export declare function getExchangeRates(from: BridgeCurrency, to: BridgeCurrency): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<BridgeExchangeRates>>;
26
27
  export declare function getExternalPayments(paymentIds: string[]): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<ExternalPayment[]>>;
@@ -39,28 +39,30 @@ exports.createBridgeBankAccount = createBridgeBankAccount;
39
39
  exports.getBridgeUser = getBridgeUser;
40
40
  exports.validateTransfer = validateTransfer;
41
41
  exports.createBridgeTransfer = createBridgeTransfer;
42
+ exports.getExchangeRates = getExchangeRates;
42
43
  exports.getExternalPayments = getExternalPayments;
43
44
  exports.BridgeClient = __importStar(require("./bridgeServiceClient"));
44
- const serviceClient_1 = require("../serviceClient");
45
+ const restClient_1 = require("../restClient");
46
+ const baseClient = (0, restClient_1.getRestClient)(process.env.BRIDGE_SERVICE_API_IAM_URL);
45
47
  const ONRAMP_ENDPOINT = "/bridge";
46
48
  const ONRAMP_ROUTER_ENDPOINT = "/v2/bridge/api";
47
49
  async function getTransferHashes(externalPaymentIds) {
48
- return serviceClient_1.baseClient
50
+ return baseClient
49
51
  .post(`${ONRAMP_ROUTER_ENDPOINT}/off-ramps/blockchain-transactions`, { externalPaymentIds })
50
52
  .then((res) => res.data);
51
53
  }
52
54
  async function createBridgeBankAccount(userId, accountId, input) {
53
- return serviceClient_1.baseClient
55
+ return baseClient
54
56
  .post(`${ONRAMP_ENDPOINT}/user/${userId}/bank-account/${accountId}`, input)
55
57
  .then((res) => res.data);
56
58
  }
57
59
  async function getBridgeUser(userId) {
58
- return serviceClient_1.baseClient
60
+ return baseClient
59
61
  .get(`${ONRAMP_ENDPOINT}/user/${userId}`)
60
62
  .then((res) => res.data);
61
63
  }
62
64
  async function validateTransfer({ userId, transferId, amount, toAddress, }) {
63
- return serviceClient_1.baseClient
65
+ return baseClient
64
66
  .post(`${ONRAMP_ENDPOINT}/transfer/validate`, {
65
67
  userId,
66
68
  transferId,
@@ -70,12 +72,19 @@ async function validateTransfer({ userId, transferId, amount, toAddress, }) {
70
72
  .then((res) => res.data);
71
73
  }
72
74
  async function createBridgeTransfer(userId, input) {
73
- return serviceClient_1.baseClient
75
+ return baseClient
74
76
  .post(`${ONRAMP_ROUTER_ENDPOINT}/off-ramps/users/${userId}/transfers`, input)
75
77
  .then((res) => res.data);
76
78
  }
79
+ async function getExchangeRates(from, to) {
80
+ return baseClient
81
+ .get(`${ONRAMP_ROUTER_ENDPOINT}/exchange-rates`, {
82
+ params: { from, to },
83
+ })
84
+ .then((res) => res.data);
85
+ }
77
86
  async function getExternalPayments(paymentIds) {
78
- return serviceClient_1.baseClient
87
+ return baseClient
79
88
  .get(`${ONRAMP_ENDPOINT}/external-payments?paymentIds=${paymentIds.join(",")}`)
80
89
  .then((res) => res.data);
81
90
  }
@@ -45,6 +45,25 @@ export declare enum BridgeNetwork {
45
45
  STELLAR = "stellar",
46
46
  TRON = "tron"
47
47
  }
48
+ /** Currencies the bridge service quotes (`GET /api/exchange-rates`). */
49
+ export declare enum BridgeCurrency {
50
+ BRL = "brl",
51
+ BTC = "btc",
52
+ ETH = "eth",
53
+ EUR = "eur",
54
+ GBP = "gbp",
55
+ MXN = "mxn",
56
+ SOL = "sol",
57
+ USD = "usd",
58
+ USDT = "usdt",
59
+ USDC = "usdc"
60
+ }
61
+ /** Bridge's quote for one `from` unit, in `to` units. Decimal strings, as Bridge returns them. */
62
+ export type BridgeExchangeRates = {
63
+ midmarket_rate: string;
64
+ buy_rate: string;
65
+ sell_rate: string;
66
+ };
48
67
  export declare enum BridgeTransferOffRampPaymentRail {
49
68
  ACH = "ach",
50
69
  ACH_SAME_DAY = "ach_same_day",
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BridgeTransferOffRampPaymentRail = exports.BridgeNetwork = void 0;
3
+ exports.BridgeTransferOffRampPaymentRail = exports.BridgeCurrency = exports.BridgeNetwork = void 0;
4
4
  var BridgeNetwork;
5
5
  (function (BridgeNetwork) {
6
6
  BridgeNetwork["ETHEREUM"] = "ethereum";
@@ -13,6 +13,20 @@ var BridgeNetwork;
13
13
  BridgeNetwork["STELLAR"] = "stellar";
14
14
  BridgeNetwork["TRON"] = "tron";
15
15
  })(BridgeNetwork || (exports.BridgeNetwork = BridgeNetwork = {}));
16
+ /** Currencies the bridge service quotes (`GET /api/exchange-rates`). */
17
+ var BridgeCurrency;
18
+ (function (BridgeCurrency) {
19
+ BridgeCurrency["BRL"] = "brl";
20
+ BridgeCurrency["BTC"] = "btc";
21
+ BridgeCurrency["ETH"] = "eth";
22
+ BridgeCurrency["EUR"] = "eur";
23
+ BridgeCurrency["GBP"] = "gbp";
24
+ BridgeCurrency["MXN"] = "mxn";
25
+ BridgeCurrency["SOL"] = "sol";
26
+ BridgeCurrency["USD"] = "usd";
27
+ BridgeCurrency["USDT"] = "usdt";
28
+ BridgeCurrency["USDC"] = "usdc";
29
+ })(BridgeCurrency || (exports.BridgeCurrency = BridgeCurrency = {}));
16
30
  var BridgeTransferOffRampPaymentRail;
17
31
  (function (BridgeTransferOffRampPaymentRail) {
18
32
  BridgeTransferOffRampPaymentRail["ACH"] = "ach";
@@ -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 serviceClient_1 = require("../serviceClient");
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1 = require("../serviceClient");
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 serviceClient_1.baseClient
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 serviceClient_1 = require("../serviceClient");
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 serviceClient_1.baseClient.post(FEATURES_ENDPOINT, payload);
84
+ return baseClient.post(FEATURES_ENDPOINT, payload);
84
85
  }
85
86
  async function getFeatureFlags() {
86
- return serviceClient_1.baseClient.get(FEATURES_ENDPOINT).then((res) => res.data);
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 serviceClient_1 = require("../serviceClient");
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1 = require("../serviceClient");
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient.post(`${LIABILITIES_V2_ENDPOINT}/checkbook/debit-card/create`, input);
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1 = require("../serviceClient");
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 serviceClient_1.baseClient
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 serviceClient_1 = require("../serviceClient");
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1 = require("../serviceClient");
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
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 serviceClient_1.baseClient
148
+ return baseClient
148
149
  .post(`${PAYABLE_ACCOUNTS_ROUTER_ENDPOINT}/debit-cards/${cardId}/unpayable`, { code, reason })
149
150
  .then((res) => res.data);
150
151
  }