@spritz-finance/service-client 0.9.0 → 0.11.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.
@@ -29,7 +29,6 @@ export declare enum FeatureFlag {
29
29
  BillPayments = "payments.accountType.bill",
30
30
  VirtualCardPayments = "payments.accountType.virtualCard",
31
31
  DebitCardPayments = "payments.accountType.debitCard",
32
- PushToCardPayments = "payments.accountType.pushToCard",
33
32
  BankAccountPayments = "payments.accountType.bankAccount",
34
33
  RtpPayments = "payments.accountType.rtp",
35
34
  CadPayments = "payments.cad.enabled",
@@ -26,7 +26,6 @@ var FeatureFlag;
26
26
  FeatureFlag["BillPayments"] = "payments.accountType.bill";
27
27
  FeatureFlag["VirtualCardPayments"] = "payments.accountType.virtualCard";
28
28
  FeatureFlag["DebitCardPayments"] = "payments.accountType.debitCard";
29
- FeatureFlag["PushToCardPayments"] = "payments.accountType.pushToCard";
30
29
  FeatureFlag["BankAccountPayments"] = "payments.accountType.bankAccount";
31
30
  FeatureFlag["RtpPayments"] = "payments.accountType.rtp";
32
31
  FeatureFlag["CadPayments"] = "payments.cad.enabled";
@@ -1,7 +1,7 @@
1
1
  export * as LiabilitiesClient from "./liabilitiesServiceClient";
2
2
  import { CheckbookUser } from "../lib/graphClient/generated";
3
3
  import { ExternalBillInput } from "../payableAccounts/types";
4
- import { CheckbookCardResponse, CheckbookDebitCardResponse, CheckbookDigitalAccountResponse, CheckbookUpdateCardResponse, CreateCheckbookUserParams, CreateDebitCardInput, CreateDigitalAccountInput, CreateEntityParams, DirectPaymentResponse, IssueRefundCreditInput, IssueRefundCreditResult, MethodFiEntity, RewardTransaction } from "./types";
4
+ import { CheckbookCardResponse, CheckbookDebitCardResponse, CheckbookDigitalAccountResponse, CheckbookUpdateCardResponse, CreateCheckbookUserParams, CreateDebitCardInput, CreateDigitalAccountInput, CreateEntityParams, CreateTokenizedDebitCardInput, DirectPaymentResponse, IssueRefundCreditInput, IssueRefundCreditResult, MethodFiEntity, RewardTransaction, TokenizedDebitCardResponse } from "./types";
5
5
  export declare function getRewardTransaction(transactionId: string): Promise<RewardTransaction>;
6
6
  export declare function createMethodFiEntity(args: CreateEntityParams): Promise<MethodFiEntity>;
7
7
  export declare function getMethodFiEntity(userId: string): Promise<MethodFiEntity | null>;
@@ -10,6 +10,14 @@ export declare function upsertCheckbookUser(args: CreateCheckbookUserParams): Pr
10
10
  export declare function getCheckbookUser(userId: string): Promise<CheckbookUser | null>;
11
11
  export declare function createCheckbookVirtualCard(userId: string): Promise<CheckbookCardResponse>;
12
12
  export declare function createCheckbookDebitCard(input: CreateDebitCardInput): Promise<CheckbookDebitCardResponse>;
13
+ /**
14
+ * Registers a debit card from a platform Evervault tokenization. Hits the same
15
+ * `/debit-card/create` route as {@link createCheckbookDebitCard}, but sends a
16
+ * `tokenizationId` instead of raw card data; liabilities relays it through the
17
+ * platform Evervault endpoint to Checkbook (gated by the `evervault.debitCards`
18
+ * flag). Throws on a non-2xx response.
19
+ */
20
+ export declare function createTokenizedDebitCard(input: CreateTokenizedDebitCardInput): Promise<TokenizedDebitCardResponse>;
13
21
  export declare function createCheckbookDigitalAccount(input: CreateDigitalAccountInput): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<CheckbookDigitalAccountResponse>>;
14
22
  export declare function createUSBillFromAccountNumber(userId: string, accountNumber: string, merchantId: string): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<ExternalBillInput>>;
15
23
  export declare function getVirtualCardBalance(cardExternalId: string, userId: string): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<number>>;
@@ -42,6 +42,7 @@ exports.upsertCheckbookUser = upsertCheckbookUser;
42
42
  exports.getCheckbookUser = getCheckbookUser;
43
43
  exports.createCheckbookVirtualCard = createCheckbookVirtualCard;
44
44
  exports.createCheckbookDebitCard = createCheckbookDebitCard;
45
+ exports.createTokenizedDebitCard = createTokenizedDebitCard;
45
46
  exports.createCheckbookDigitalAccount = createCheckbookDigitalAccount;
46
47
  exports.createUSBillFromAccountNumber = createUSBillFromAccountNumber;
47
48
  exports.getVirtualCardBalance = getVirtualCardBalance;
@@ -95,6 +96,29 @@ async function createCheckbookDebitCard(input) {
95
96
  .post(`${LIABILITIES_ENDPOINT}/debit-card/create`, input)
96
97
  .then((res) => res.data);
97
98
  }
99
+ /**
100
+ * Registers a debit card from a platform Evervault tokenization. Hits the same
101
+ * `/debit-card/create` route as {@link createCheckbookDebitCard}, but sends a
102
+ * `tokenizationId` instead of raw card data; liabilities relays it through the
103
+ * platform Evervault endpoint to Checkbook (gated by the `evervault.debitCards`
104
+ * flag). Throws on a non-2xx response.
105
+ */
106
+ async function createTokenizedDebitCard(input) {
107
+ var _a, _b;
108
+ // Served by the Hono ServiceApi (30s timeout), which wraps the result in the
109
+ // standard `{ status, data }` envelope. Unwrap it here so callers keep the
110
+ // simple `{ externalId, cardLast4 }` contract; surface the provider error
111
+ // 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 body = res.data;
114
+ if (body.status === "failure") {
115
+ 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");
116
+ }
117
+ return {
118
+ externalId: body.data.checkbookCardId,
119
+ cardLast4: body.data.cardLast4,
120
+ };
121
+ }
98
122
  async function createCheckbookDigitalAccount(input) {
99
123
  return serviceClient_1.baseClient
100
124
  .post(`${LIABILITIES_ENDPOINT}/digital-account/create`, input)
@@ -186,6 +186,34 @@ export type CreateDigitalAccountInput = {
186
186
  identifier: string;
187
187
  type: DigitalAccountType;
188
188
  };
189
+ /**
190
+ * Input for registering a debit card from a platform Evervault tokenization.
191
+ * The raw PAN never leaves the platform — liabilities looks the tokenization
192
+ * up and relays it through Evervault to Checkbook. `cardholderName`/`cardBin`
193
+ * are forwarded for the relay path and ignored by the legacy direct path.
194
+ */
195
+ export type CreateTokenizedDebitCardInput = {
196
+ userId: string;
197
+ tokenizationId: string;
198
+ cardholderName: string;
199
+ cardBin: string;
200
+ };
201
+ /**
202
+ * Raw body returned by liabilities `POST /debit-card/create` on the relay path.
203
+ */
204
+ export type RelayDebitCardResponse = {
205
+ userId: string;
206
+ checkbookCardId: string;
207
+ cardLast4: string;
208
+ };
209
+ /**
210
+ * Normalized result of {@link createTokenizedDebitCard}. `externalId` is the
211
+ * Checkbook card id (mapped from the relay path's `checkbookCardId`).
212
+ */
213
+ export type TokenizedDebitCardResponse = {
214
+ externalId: string;
215
+ cardLast4: string;
216
+ };
189
217
  export type CheckbookDebitCardResponse = {
190
218
  userId: string;
191
219
  externalId: string;
@@ -1,5 +1,5 @@
1
1
  export * as PlatformClient from "./platformServiceClient";
2
- import { IssuePayoutData, IssuePayoutRequest, MTBalancesData, PlaidTreasuryBalancesData, SendPaymentData, SendPaymentRequest, TabapayBalancesResponse, TabapayFundingRequirementResponse, ValidateBillData, ValidateBillRequest } from "./types";
2
+ import { IssuePayoutData, IssuePayoutRequest, MTBalancesData, PlaidTreasuryBalancesData, RelayCheckbookCardData, RelayCheckbookCardRequest, SendPaymentData, SendPaymentRequest, TabapayBalancesResponse, TabapayFundingRequirementResponse, ValidateBillData, ValidateBillRequest } from "./types";
3
3
  export declare function validateBill(request: ValidateBillRequest): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<ValidateBillData>>;
4
4
  export declare function tabapayBalances(): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<TabapayBalancesResponse>>;
5
5
  export declare function tabapayFundingRequirement(currency?: string): Promise<TabapayFundingRequirementResponse>;
@@ -11,3 +11,10 @@ export declare function modernTreasuryBalances(): Promise<import("../types").Api
11
11
  * from the platform's snapshot cache and refreshed at most every few hours.
12
12
  */
13
13
  export declare function plaidTreasuryBalances(): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<PlaidTreasuryBalancesData>>;
14
+ /**
15
+ * Registers a tokenized debit card with Checkbook via the platform's Evervault
16
+ * relay. Platform holds the Evervault credentials and the tokenized card data;
17
+ * the caller (liabilities) supplies the per-user Checkbook API credentials. The
18
+ * raw PAN is decrypted in-flight by the relay and never returned.
19
+ */
20
+ export declare function relayCheckbookCard(request: RelayCheckbookCardRequest): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<RelayCheckbookCardData>>;
@@ -44,6 +44,7 @@ exports.issuePayout = issuePayout;
44
44
  exports.sendPayment = sendPayment;
45
45
  exports.modernTreasuryBalances = modernTreasuryBalances;
46
46
  exports.plaidTreasuryBalances = plaidTreasuryBalances;
47
+ exports.relayCheckbookCard = relayCheckbookCard;
47
48
  exports.PlatformClient = __importStar(require("./platformServiceClient"));
48
49
  const axios_1 = __importDefault(require("axios"));
49
50
  // @ts-expect-error no type declarations for axios-token-interceptor
@@ -104,3 +105,15 @@ async function plaidTreasuryBalances() {
104
105
  .get(`${PLAID_TREASURY_ENDPOINT}/balances`)
105
106
  .then((res) => res.data);
106
107
  }
108
+ const EVERVAULT_RELAY_ENDPOINT = "/v1/evervault/relay/checkbook/cards";
109
+ /**
110
+ * Registers a tokenized debit card with Checkbook via the platform's Evervault
111
+ * relay. Platform holds the Evervault credentials and the tokenized card data;
112
+ * the caller (liabilities) supplies the per-user Checkbook API credentials. The
113
+ * raw PAN is decrypted in-flight by the relay and never returned.
114
+ */
115
+ async function relayCheckbookCard(request) {
116
+ return platformClient
117
+ .post(EVERVAULT_RELAY_ENDPOINT, request)
118
+ .then((res) => res.data);
119
+ }
@@ -108,3 +108,14 @@ export interface PlaidTreasuryAccountBalance {
108
108
  export interface PlaidTreasuryBalancesData {
109
109
  accounts: PlaidTreasuryAccountBalance[];
110
110
  }
111
+ export interface RelayCheckbookCardRequest {
112
+ tokenization_id: string;
113
+ user_id: string;
114
+ checkbook_user_id: string;
115
+ checkbook_api_key: string;
116
+ checkbook_api_secret: string;
117
+ }
118
+ export interface RelayCheckbookCardData {
119
+ checkbook_card_id: string;
120
+ card_last4: string;
121
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spritz-finance/service-client",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "gitHead": "06f8e96b7b38c34df26a38da329331940675e4f8",
5
5
  "description": "Service client",
6
6
  "license": "ISC",