squarefi-bff-api-module 1.36.47 → 1.36.48

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.
@@ -23,8 +23,18 @@ export declare const frontend: {
23
23
  limits: {
24
24
  update: ({ card_id, ...data }: API.Frontend.Issuing.Cards.Limits.Request) => Promise<API.Frontend.Issuing.Cards.Limits.Response>;
25
25
  };
26
- /** Card PAN/CVV, encrypted for the caller's key. */
26
+ /**
27
+ * PLAINTEXT PAN/CVV — server-to-server only. In a browser or mobile client use
28
+ * `sensitiveEncrypted` instead, so the card number never travels readable.
29
+ */
27
30
  sensitive: ({ card_id, }: API.Frontend.Issuing.Cards.Sensitive.Request) => Promise<API.Frontend.Issuing.Cards.Sensitive.Response>;
31
+ /**
32
+ * PAN/CVV over the encrypted channel: generates an AES-256 key, sends it encrypted to
33
+ * the server's RSA public key (`SERVER_PUBLIC_KEY_BASE64`) and decrypts the answer —
34
+ * the same exchange as the legacy `issuing.cards.sensitiveData.encrypted.secretKey`,
35
+ * against the frontend route.
36
+ */
37
+ sensitiveEncrypted: ({ card_id, }: API.Frontend.Issuing.Cards.SensitiveEncrypted.Request) => Promise<API.Frontend.Issuing.Cards.SensitiveEncrypted.Response>;
28
38
  transactions: ({ card_id, ...params }: API.Frontend.Issuing.Cards.Transactions.Request) => Promise<API.Frontend.Issuing.Cards.Transactions.Response>;
29
39
  create: (data: API.Frontend.Issuing.Cards.Create.Request) => Promise<API.Frontend.Issuing.Cards.Create.Response>;
30
40
  };
@@ -1,4 +1,5 @@
1
1
  import { apiClientV1, apiClientV1Frontend } from '../utils/apiClientFactory';
2
+ import { makeSecureRequest } from '../utils/encrypt';
2
3
  export const frontend = {
3
4
  access: {
4
5
  keys: {
@@ -39,8 +40,27 @@ export const frontend = {
39
40
  limits: {
40
41
  update: ({ card_id, ...data }) => apiClientV1Frontend.putRequest(`/frontend/issuing/cards/${card_id}/limits`, { data }),
41
42
  },
42
- /** Card PAN/CVV, encrypted for the caller's key. */
43
+ /**
44
+ * PLAINTEXT PAN/CVV — server-to-server only. In a browser or mobile client use
45
+ * `sensitiveEncrypted` instead, so the card number never travels readable.
46
+ */
43
47
  sensitive: ({ card_id, }) => apiClientV1Frontend.getRequest(`/frontend/issuing/cards/${card_id}/sensitive`),
48
+ /**
49
+ * PAN/CVV over the encrypted channel: generates an AES-256 key, sends it encrypted to
50
+ * the server's RSA public key (`SERVER_PUBLIC_KEY_BASE64`) and decrypts the answer —
51
+ * the same exchange as the legacy `issuing.cards.sensitiveData.encrypted.secretKey`,
52
+ * against the frontend route.
53
+ */
54
+ sensitiveEncrypted: async ({ card_id, }) => {
55
+ const serverPublicKey = process.env.SERVER_PUBLIC_KEY_BASE64;
56
+ if (!serverPublicKey) {
57
+ throw new Error('SERVER_PUBLIC_KEY_BASE64 is not set');
58
+ }
59
+ return makeSecureRequest({
60
+ callback: (props) => apiClientV1Frontend.postRequest(`/frontend/issuing/cards/${card_id}/sensitive/secretkey`, { data: props }),
61
+ publicKey: serverPublicKey,
62
+ });
63
+ },
44
64
  transactions: ({ card_id, ...params }) => apiClientV1Frontend.getRequest(`/frontend/issuing/cards/${card_id}/transactions`, { params }),
45
65
  create: (data) => apiClientV1Frontend.postRequest('/frontend/issuing/cards', {
46
66
  data,
@@ -2058,6 +2058,8 @@ export interface paths {
2058
2058
  wallet_id?: string;
2059
2059
  /** @description Filter cards by program ID */
2060
2060
  program_id?: string;
2061
+ /** @description Only cards drawing from this sub-account. */
2062
+ sub_account_id?: string;
2061
2063
  /** @description Filter cards by program sub-account type (prepaid or balance) */
2062
2064
  sub_account_type?: "prepaid" | "balance";
2063
2065
  /** @description Filter cards by status (matches issuing_cards.card_status).
@@ -2595,6 +2597,89 @@ export interface paths {
2595
2597
  patch?: never;
2596
2598
  trace?: never;
2597
2599
  };
2600
+ "/frontend/issuing/cards/{card_id}/sensitive/secretkey": {
2601
+ parameters: {
2602
+ query?: never;
2603
+ header?: never;
2604
+ path?: never;
2605
+ cookie?: never;
2606
+ };
2607
+ get?: never;
2608
+ put?: never;
2609
+ /**
2610
+ * Get card sensitive data over an encrypted channel
2611
+ * @description PAN / CVV without ever putting them in a readable response body — prefer this
2612
+ * over `GET /sensitive` in any browser or mobile client.
2613
+ *
2614
+ * The client generates a 32-byte AES-256 key, encrypts it to the server's RSA
2615
+ * public key (`RSA-OAEP`; `PKCS1` is accepted for older clients) and sends it
2616
+ * base64-encoded as `encrypted_key`. The response carries the card data
2617
+ * AES-256-CBC encrypted with that same key, plus the `iv` used.
2618
+ *
2619
+ * Decrypting `data` with the key and IV yields
2620
+ * `{ success, data: { card_number, cvv, expiry_month, expiry_year, security_code }, timestamp }`.
2621
+ *
2622
+ * **Access**: ADMIN on the card's wallet, or the scoped `user` role on their OWN card.
2623
+ *
2624
+ */
2625
+ post: {
2626
+ parameters: {
2627
+ query?: never;
2628
+ header?: never;
2629
+ path: {
2630
+ card_id: string;
2631
+ };
2632
+ cookie?: never;
2633
+ };
2634
+ requestBody: {
2635
+ content: {
2636
+ "application/json": {
2637
+ /** @description Base64 of the AES-256 key encrypted to the server's RSA public key. */
2638
+ encrypted_key: string;
2639
+ };
2640
+ };
2641
+ };
2642
+ responses: {
2643
+ /** @description Encrypted sensitive data */
2644
+ 200: {
2645
+ headers: {
2646
+ [name: string]: unknown;
2647
+ };
2648
+ content: {
2649
+ "application/json": {
2650
+ /** @example true */
2651
+ success: boolean;
2652
+ /** @example true */
2653
+ encrypted: boolean;
2654
+ /** @description Base64 AES-256-CBC ciphertext of the sensitive-data envelope. */
2655
+ data: string;
2656
+ /** @description Base64 IV used for the AES encryption. */
2657
+ iv: string;
2658
+ };
2659
+ };
2660
+ };
2661
+ /** @description Missing or undecryptable `encrypted_key`, or a key that is not 32 bytes */
2662
+ 400: {
2663
+ headers: {
2664
+ [name: string]: unknown;
2665
+ };
2666
+ content?: never;
2667
+ };
2668
+ /** @description Server key not configured, or encryption failed */
2669
+ 500: {
2670
+ headers: {
2671
+ [name: string]: unknown;
2672
+ };
2673
+ content?: never;
2674
+ };
2675
+ };
2676
+ };
2677
+ delete?: never;
2678
+ options?: never;
2679
+ head?: never;
2680
+ patch?: never;
2681
+ trace?: never;
2682
+ };
2598
2683
  "/frontend/issuing/cards/{card_id}/freeze": {
2599
2684
  parameters: {
2600
2685
  query?: never;
@@ -12257,11 +12342,12 @@ export interface components {
12257
12342
  [key: string]: unknown;
12258
12343
  } | null;
12259
12344
  };
12260
- /** @description Sub-account funding a card — the subset of `fiat_accounts` columns joined onto each card. */
12345
+ /** @description Sub-account funding a card — the `fiat_accounts` row joined onto each card, with the same `currency` / `issuing_program` / `account_details` enrichment `GET /sub-accounts` applies, so a card page can drive top-up and render balances without a second request. */
12261
12346
  IssuingCardSubAccount: {
12262
12347
  /** Format: uuid */
12263
12348
  id: string;
12264
12349
  nick_name?: string | null;
12350
+ /** @description Live balance from the issuing ledger (falls back to the cached column). */
12265
12351
  balance?: number | null;
12266
12352
  /** @enum {string} */
12267
12353
  type: "balance" | "prepaid";
@@ -12275,6 +12361,11 @@ export interface components {
12275
12361
  * @description crypto.uuid of the account currency
12276
12362
  */
12277
12363
  account_currency: string;
12364
+ currency?: components["schemas"]["CurrencyRef"];
12365
+ /** @description Program embed (carries `order_types`, which the top-up flow reads); null when program_id is null. */
12366
+ issuing_program?: components["schemas"]["IssuingProgram"] | null;
12367
+ /** @description Bank details from the vendor meta; empty string `""` when none are available. */
12368
+ account_details?: components["schemas"]["BankAccountDetails"] | "";
12278
12369
  /** Format: uuid */
12279
12370
  program_id?: string | null;
12280
12371
  /** Format: uuid */
@@ -788,13 +788,28 @@ export declare namespace API {
788
788
  } & CardLimitsRoot['put']['requestBody']['content']['application/json'];
789
789
  type Response = CardLimitsRoot['put']['responses']['200']['content']['application/json'];
790
790
  }
791
- /** Card PAN/CVV, encrypted for the caller's key. */
791
+ /**
792
+ * Card PAN/CVV in PLAINTEXT. Server-to-server only — a browser or mobile client
793
+ * should use `SensitiveEncrypted`, which never puts the PAN in a readable body.
794
+ */
792
795
  namespace Sensitive {
793
796
  type Request = {
794
797
  card_id: string;
795
798
  };
796
799
  type Response = CardSensitiveRoot['get']['responses']['200']['content']['application/json'];
797
800
  }
801
+ /**
802
+ * Card PAN/CVV over an end-to-end encrypted channel: the client's AES-256 key is
803
+ * sent encrypted to the server's RSA public key, and the answer comes back
804
+ * encrypted with that same key. The SDK does the key exchange and the decryption,
805
+ * so the caller just receives the decrypted payload.
806
+ */
807
+ namespace SensitiveEncrypted {
808
+ type Request = {
809
+ card_id: string;
810
+ };
811
+ type Response = API.Cards.SensitiveData;
812
+ }
798
813
  namespace Transactions {
799
814
  type Request = {
800
815
  card_id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squarefi-bff-api-module",
3
- "version": "1.36.47",
3
+ "version": "1.36.48",
4
4
  "description": "Squarefi BFF API client module",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",