@tesouro/embedded-components-react 0.3.36 → 0.3.38

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.
Files changed (22) hide show
  1. package/README.md +10 -10
  2. package/dist/index.d.ts +31 -0
  3. package/dist/lib/CardDetailsWidget.d.ts +31 -0
  4. package/dist/lib/CardsWidget.d.ts +31 -0
  5. package/dist/libs/tesouro-embedded-components-react/card-details-widget/data-access/dist/index.js +3 -2
  6. package/dist/libs/tesouro-embedded-components-react/card-details-widget/data-access/dist/index5.js +16 -9
  7. package/dist/libs/tesouro-embedded-components-react/card-details-widget/data-access/dist/index6.js +25 -0
  8. package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/index3.js +36 -6
  9. package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/index4.js +34 -11
  10. package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/index5.js +13 -1
  11. package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/index6.js +118 -59
  12. package/dist/libs/tesouro-embedded-components-react/card-details-widget/ui/dist/lib/CardDetailsPanel/CardDetailsPanel.js +151 -124
  13. package/dist/libs/tesouro-embedded-components-react/card-details-widget/ui/dist/lib/CardDetailsPanel/labels.js +3 -0
  14. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +21 -19
  15. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/apiErrorStatus.js +26 -0
  16. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/isApiForbiddenError.js +7 -0
  17. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/isApiNotFoundError.js +4 -23
  18. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/isUserDataNotFoundError.js +7 -6
  19. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +177 -166
  20. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +139 -127
  21. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  22. package/package.json +1 -1
package/README.md CHANGED
@@ -272,19 +272,19 @@ One page of an organization's credit **or** debit cards, with a scope-gated "Sho
272
272
 
273
273
  ### CardDetailsWidget
274
274
 
275
- Read-only details for one credit **or** debit card — status, form factor, program, masked card number, and copyable cardholder and nickname rows. It renders panel content rather than its own drawer, so it sits on a page of your own as readily as inside chrome you already have.
275
+ Read-only details for one credit **or** debit card — status, form factor, program, masked card number, and copyable cardholder and nickname rows. A debit card can also reveal its number, expiry and security code on demand. It renders panel content rather than its own drawer, so it sits on a page of your own as readily as inside chrome you already have.
276
276
 
277
277
  #### Props
278
278
 
279
- | Prop | Type | Default | Description |
280
- | ---------------- | --------------------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
281
- | `cardId` | `string` | **Required** | Id of the card to show. |
282
- | `cardProgram` | `'credit' \| 'debit'` | **Required** | Which issuing program `cardId` belongs to. Selects the endpoint the card is fetched from. |
283
- | `onClose` | `() => void` | `undefined` | Called when the header's close control is pressed. Omit it and no close control is rendered at all. |
284
- | `labels` | `PartialDeep<CardDetailsWidgetLabels>` | English labels | Overrides the panel's own copy — header, card face alt text, row headings, copy-button accessible names, and the loading/error/not-found screens. |
285
- | `featureLabels` | `PartialDeep<CardDetailsFeatureLabels>` | English labels | Overrides the copy this widget resolves rather than passes through — status, form-factor and program vocabulary, plus the copy-success toast. |
286
- | `bankLogoSrc` | `string` | `undefined` | Bank logo for the card face. Omit and the face renders without a logo rather than with a placeholder. |
287
- | `bankLogoAlt` | `string` | `undefined` | Alt text for `bankLogoSrc`. Falls back to `labels.cardFace.bankLogoAlt`. |
279
+ | Prop | Type | Default | Description |
280
+ | ---------------- | --------------------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
281
+ | `cardId` | `string` | **Required** | Id of the card to show. |
282
+ | `cardProgram` | `'credit' \| 'debit'` | **Required** | Which issuing program `cardId` belongs to. Selects the endpoint the card is fetched from. |
283
+ | `onClose` | `() => void` | `undefined` | Called when the header's close control is pressed. Omit it and no close control is rendered at all. |
284
+ | `labels` | `PartialDeep<CardDetailsWidgetLabels>` | English labels | Overrides the panel's own copy — header, card face alt text, row headings, copy-button accessible names, and the loading/error/not-found screens. |
285
+ | `featureLabels` | `PartialDeep<CardDetailsFeatureLabels>` | English labels | Overrides the copy this widget resolves rather than passes through — status, form-factor and program vocabulary, the copy-success toast, and the refused-reveal sentence. |
286
+ | `bankLogoSrc` | `string` | `undefined` | Bank logo for the card face. Omit and the face renders without a logo rather than with a placeholder. |
287
+ | `bankLogoAlt` | `string` | `undefined` | Alt text for `bankLogoSrc`. Falls back to `labels.cardFace.bankLogoAlt`. |
288
288
 
289
289
  ### CreateCardWidget
290
290
 
package/dist/index.d.ts CHANGED
@@ -456,6 +456,11 @@ type CreditCardStatus = 'PENDING_ACTIVATION' | 'ACTIVE' | 'LOCKED' | 'CLOSED';
456
456
  type CreditCardType = 'DIGITAL' | 'PHYSICAL';
457
457
  type DisclosureRequirement = 'NOT_REQUIRED' | 'REQUIRED';
458
458
  type OrganizationType = 'BANK' | 'EMBEDDED' | 'PLATFORM' | 'TRANSACTOR' | 'VERTICAL_SOFTWARE_PROVIDER';
459
+ /**
460
+ * The rolling period a velocity control's amount and usage limits are evaluated over.
461
+ * `TRANSACTION` applies the limit per-transaction and therefore carries no usage limit.
462
+ */
463
+ type VelocityWindow = 'DAY' | 'LIFETIME' | 'MONTH' | 'TRANSACTION' | 'WEEK';
459
464
  type WidgetInitResponse = {
460
465
  bankName?: null | string;
461
466
  /**
@@ -2160,7 +2165,11 @@ interface CardDetailsFieldLabels {
2160
2165
  cardholder: string;
2161
2166
  nickname: string;
2162
2167
  billingAddress: string;
2168
+ /** Sub-header over the merchant categories / velocity control rows. */
2169
+ cardControlsHeading: string;
2163
2170
  allowedCategories: string;
2171
+ spendLimit: string;
2172
+ perTransactionMax: string;
2164
2173
  /** Stands in for a row whose value the card does not carry. */
2165
2174
  emptyValue: string;
2166
2175
  copyCardholderAriaLabel: string;
@@ -2235,12 +2244,34 @@ type PartialDeep$3<T> = {
2235
2244
  interface CardDetailsFeatureLabels {
2236
2245
  /** Confirmation toast after a copy affordance writes to the clipboard. */
2237
2246
  copySuccessToast: string;
2247
+ /**
2248
+ * Replaces the panel's generic reveal error when the credentials call was
2249
+ * refused (HTTP 403).
2250
+ *
2251
+ * It lives here rather than on the panel because deciding that a failure was a
2252
+ * refusal means reading the error, which is this layer's job — the panel is
2253
+ * handed one already-chosen sentence either way, and its own
2254
+ * `credentials.errorDescription` still covers every other failure.
2255
+ *
2256
+ * The wording deliberately does not tell the reader to ask for a permission.
2257
+ * Reading a debit card and reading its credentials take the same scope, so a
2258
+ * reader looking at this panel already holds it; a 403 here means the call was
2259
+ * refused for this session, which asking an admin for a role will not fix.
2260
+ */
2261
+ revealNotPermittedDescription: string;
2238
2262
  /** Program wording on the card face, keyed on the widget's `cardProgram`. */
2239
2263
  programLabels: Record<CardProgram, string>;
2240
2264
  /** Status badge wording, keyed on the generated card status. */
2241
2265
  statusLabels: Record<CardStatus, string>;
2242
2266
  /** Form-factor subtitle wording, keyed on the generated card type. */
2243
2267
  formFactorLabels: Record<CardType, string>;
2268
+ /**
2269
+ * A velocity control's reset-period wording, keyed on the generated
2270
+ * `velocityWindow`. Used to build the spend limit row, e.g. "$500 / month".
2271
+ * `TRANSACTION` is unused there (it drives the separate per-transaction max
2272
+ * row instead) but is still a real enum member, so it stays in the map.
2273
+ */
2274
+ velocityWindowLabels: Record<VelocityWindow, string>;
2244
2275
  }
2245
2276
 
2246
2277
  interface CardDetailsWidgetProps extends WidgetProviderProps {
@@ -21,7 +21,11 @@ interface CardDetailsFieldLabels {
21
21
  cardholder: string;
22
22
  nickname: string;
23
23
  billingAddress: string;
24
+ /** Sub-header over the merchant categories / velocity control rows. */
25
+ cardControlsHeading: string;
24
26
  allowedCategories: string;
27
+ spendLimit: string;
28
+ perTransactionMax: string;
25
29
  /** Stands in for a row whose value the card does not carry. */
26
30
  emptyValue: string;
27
31
  copyCardholderAriaLabel: string;
@@ -396,6 +400,11 @@ type ClientOptions = {
396
400
  };
397
401
  type CreditCardStatus = 'PENDING_ACTIVATION' | 'ACTIVE' | 'LOCKED' | 'CLOSED';
398
402
  type CreditCardType = 'DIGITAL' | 'PHYSICAL';
403
+ /**
404
+ * The rolling period a velocity control's amount and usage limits are evaluated over.
405
+ * `TRANSACTION` applies the limit per-transaction and therefore carries no usage limit.
406
+ */
407
+ type VelocityWindow = 'DAY' | 'LIFETIME' | 'MONTH' | 'TRANSACTION' | 'WEEK';
399
408
 
400
409
  type EmbeddedClient = Client;
401
410
  type ExtractLiterals<T> = T extends string ? string extends T ? never : T : never;
@@ -764,12 +773,34 @@ type PartialDeep<T> = {
764
773
  interface CardDetailsFeatureLabels {
765
774
  /** Confirmation toast after a copy affordance writes to the clipboard. */
766
775
  copySuccessToast: string;
776
+ /**
777
+ * Replaces the panel's generic reveal error when the credentials call was
778
+ * refused (HTTP 403).
779
+ *
780
+ * It lives here rather than on the panel because deciding that a failure was a
781
+ * refusal means reading the error, which is this layer's job — the panel is
782
+ * handed one already-chosen sentence either way, and its own
783
+ * `credentials.errorDescription` still covers every other failure.
784
+ *
785
+ * The wording deliberately does not tell the reader to ask for a permission.
786
+ * Reading a debit card and reading its credentials take the same scope, so a
787
+ * reader looking at this panel already holds it; a 403 here means the call was
788
+ * refused for this session, which asking an admin for a role will not fix.
789
+ */
790
+ revealNotPermittedDescription: string;
767
791
  /** Program wording on the card face, keyed on the widget's `cardProgram`. */
768
792
  programLabels: Record<CardProgram, string>;
769
793
  /** Status badge wording, keyed on the generated card status. */
770
794
  statusLabels: Record<CardStatus, string>;
771
795
  /** Form-factor subtitle wording, keyed on the generated card type. */
772
796
  formFactorLabels: Record<CardType, string>;
797
+ /**
798
+ * A velocity control's reset-period wording, keyed on the generated
799
+ * `velocityWindow`. Used to build the spend limit row, e.g. "$500 / month".
800
+ * `TRANSACTION` is unused there (it drives the separate per-transaction max
801
+ * row instead) but is still a real enum member, so it stays in the map.
802
+ */
803
+ velocityWindowLabels: Record<VelocityWindow, string>;
773
804
  }
774
805
 
775
806
  interface CardDetailsWidgetProps extends WidgetProviderProps {
@@ -436,6 +436,11 @@ type ClientOptions = {
436
436
  };
437
437
  type CreditCardStatus = 'PENDING_ACTIVATION' | 'ACTIVE' | 'LOCKED' | 'CLOSED';
438
438
  type CreditCardType = 'DIGITAL' | 'PHYSICAL';
439
+ /**
440
+ * The rolling period a velocity control's amount and usage limits are evaluated over.
441
+ * `TRANSACTION` applies the limit per-transaction and therefore carries no usage limit.
442
+ */
443
+ type VelocityWindow = 'DAY' | 'LIFETIME' | 'MONTH' | 'TRANSACTION' | 'WEEK';
439
444
 
440
445
  type EmbeddedClient = Client;
441
446
  type ExtractLiterals<T> = T extends string ? string extends T ? never : T : never;
@@ -776,7 +781,11 @@ interface CardDetailsFieldLabels {
776
781
  cardholder: string;
777
782
  nickname: string;
778
783
  billingAddress: string;
784
+ /** Sub-header over the merchant categories / velocity control rows. */
785
+ cardControlsHeading: string;
779
786
  allowedCategories: string;
787
+ spendLimit: string;
788
+ perTransactionMax: string;
780
789
  /** Stands in for a row whose value the card does not carry. */
781
790
  emptyValue: string;
782
791
  copyCardholderAriaLabel: string;
@@ -851,12 +860,34 @@ type PartialDeep$2<T> = {
851
860
  interface CardDetailsFeatureLabels {
852
861
  /** Confirmation toast after a copy affordance writes to the clipboard. */
853
862
  copySuccessToast: string;
863
+ /**
864
+ * Replaces the panel's generic reveal error when the credentials call was
865
+ * refused (HTTP 403).
866
+ *
867
+ * It lives here rather than on the panel because deciding that a failure was a
868
+ * refusal means reading the error, which is this layer's job — the panel is
869
+ * handed one already-chosen sentence either way, and its own
870
+ * `credentials.errorDescription` still covers every other failure.
871
+ *
872
+ * The wording deliberately does not tell the reader to ask for a permission.
873
+ * Reading a debit card and reading its credentials take the same scope, so a
874
+ * reader looking at this panel already holds it; a 403 here means the call was
875
+ * refused for this session, which asking an admin for a role will not fix.
876
+ */
877
+ revealNotPermittedDescription: string;
854
878
  /** Program wording on the card face, keyed on the widget's `cardProgram`. */
855
879
  programLabels: Record<CardProgram, string>;
856
880
  /** Status badge wording, keyed on the generated card status. */
857
881
  statusLabels: Record<CardStatus, string>;
858
882
  /** Form-factor subtitle wording, keyed on the generated card type. */
859
883
  formFactorLabels: Record<CardType, string>;
884
+ /**
885
+ * A velocity control's reset-period wording, keyed on the generated
886
+ * `velocityWindow`. Used to build the spend limit row, e.g. "$500 / month".
887
+ * `TRANSACTION` is unused there (it drives the separate per-transaction max
888
+ * row instead) but is still a real enum member, so it stays in the map.
889
+ */
890
+ velocityWindowLabels: Record<VelocityWindow, string>;
860
891
  }
861
892
 
862
893
  interface CardDetailsWidgetProps extends WidgetProviderProps {
@@ -1,4 +1,5 @@
1
1
  import "./index2.js";
2
2
  import { useCreditCardDetailsQuery as e } from "./index4.js";
3
- import { useDebitCardDetailsQuery as t } from "./index5.js";
4
- export { e as useCreditCardDetailsQuery, t as useDebitCardDetailsQuery };
3
+ import { useDebitCardCredentialsQuery as t } from "./index5.js";
4
+ import { useDebitCardDetailsQuery as n } from "./index6.js";
5
+ export { e as useCreditCardDetailsQuery, t as useDebitCardCredentialsQuery, n as useDebitCardDetailsQuery };
@@ -4,22 +4,29 @@
4
4
  "use client";
5
5
  import { useEmbedApi as e } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
6
6
  import { organizationHeaders as t } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
7
- import { getDebitCardByIdOptions as n } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
7
+ import { getDebitCardCredentialsOptions as n } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
8
8
  import { withAuthEpoch as r } from "../../../shared/data-access/dist/lib/withAuthEpoch.js";
9
+ import { isApiForbiddenError as i } from "../../../shared/data-access/dist/lib/isApiForbiddenError.js";
9
10
  import "../../../shared/data-access/dist/index.js";
10
- import { withNotFoundOutcome as i } from "./index3.js";
11
11
  import { useQuery as a } from "@tanstack/react-query";
12
12
  //#region ../../libs/tesouro-embedded-components-react/card-details-widget/data-access/dist/index5.js
13
13
  function o({ cardId: o, enabled: s }) {
14
- let { client: c, organizationId: l, widgetToken: u, authEpoch: d } = e(), f = n({
14
+ let { client: c, organizationId: l, widgetToken: u, authEpoch: d } = e(), f = !!(o && l && u) && s, p = f ? o ?? "" : "", m = n({
15
15
  client: c,
16
16
  headers: t(l),
17
- path: { id: o ?? "" }
18
- }), p = a({
19
- ...r(f, d),
20
- enabled: !!(o && l && u) && s !== !1
17
+ path: { id: p }
18
+ }), h = a({
19
+ ...r(m, d),
20
+ enabled: f,
21
+ staleTime: 0,
22
+ gcTime: 0,
23
+ retry: !1,
24
+ placeholderData: void 0
21
25
  });
22
- return i(p);
26
+ return {
27
+ ...h,
28
+ isForbidden: h.isError && i(h.error)
29
+ };
23
30
  }
24
31
  //#endregion
25
- export { o as useDebitCardDetailsQuery };
32
+ export { o as useDebitCardCredentialsQuery };
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { useEmbedApi as e } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
6
+ import { organizationHeaders as t } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
7
+ import { getDebitCardByIdOptions as n } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
8
+ import { withAuthEpoch as r } from "../../../shared/data-access/dist/lib/withAuthEpoch.js";
9
+ import "../../../shared/data-access/dist/index.js";
10
+ import { withNotFoundOutcome as i } from "./index3.js";
11
+ import { useQuery as a } from "@tanstack/react-query";
12
+ //#region ../../libs/tesouro-embedded-components-react/card-details-widget/data-access/dist/index6.js
13
+ function o({ cardId: o, enabled: s }) {
14
+ let { client: c, organizationId: l, widgetToken: u, authEpoch: d } = e(), f = n({
15
+ client: c,
16
+ headers: t(l),
17
+ path: { id: o ?? "" }
18
+ }), p = a({
19
+ ...r(f, d),
20
+ enabled: !!(o && l && u) && s !== !1
21
+ });
22
+ return i(p);
23
+ }
24
+ //#endregion
25
+ export { o as useDebitCardDetailsQuery };
@@ -1,10 +1,30 @@
1
+ import { amountOutputToMajorUnits as e } from "../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
1
2
  //#region ../../libs/tesouro-embedded-components-react/card-details-widget/feature/dist/index3.js
2
- var e = "••••";
3
- function t(t) {
4
- let n = t.trim().slice(-4);
5
- return n ? `${e} ${e} ${e} ${n}` : "";
3
+ var t = "••••";
4
+ function n(e) {
5
+ let n = e.trim().slice(-4);
6
+ return n ? `${t} ${t} ${t} ${n}` : "";
6
7
  }
7
- async function n(e) {
8
+ function r(e) {
9
+ let t = e.replace(/\s+/g, "");
10
+ return t ? (t.match(/.{1,4}/g) ?? []).join(" ") : "";
11
+ }
12
+ function i(e) {
13
+ let t = e.trim();
14
+ if (!t) return "";
15
+ let n = /^(\d{4})-(\d{2})(?:\D|$)/.exec(t);
16
+ if (n) {
17
+ let [, e, t] = n;
18
+ return `${t}/${e.slice(-2)}`;
19
+ }
20
+ let r = /^(\d{2})\/(\d{2}|\d{4})$/.exec(t);
21
+ if (r) {
22
+ let [, e, t] = r;
23
+ return `${e}/${t.slice(-2)}`;
24
+ }
25
+ return t;
26
+ }
27
+ async function a(e) {
8
28
  if (!e.trim()) return !1;
9
29
  try {
10
30
  return await navigator.clipboard.writeText(e), !0;
@@ -12,5 +32,15 @@ async function n(e) {
12
32
  return !1;
13
33
  }
14
34
  }
35
+ function o({ amountLimit: t, currencyCode: n }) {
36
+ let r = e({
37
+ value: t,
38
+ currencyCode: n
39
+ });
40
+ if (Number.isFinite(r)) return new Intl.NumberFormat(void 0, {
41
+ style: "currency",
42
+ currency: n
43
+ }).format(r);
44
+ }
15
45
  //#endregion
16
- export { n as copyTextToClipboard, t as maskCardNumber };
46
+ export { a as copyTextToClipboard, r as formatCardNumber, i as formatExpirationDate, o as formatVelocityControlAmount, n as maskCardNumber };
@@ -1,30 +1,53 @@
1
1
  import { CardProgram as e } from "../../../shared/feature/dist/lib/card/cardProgram.js";
2
2
  import { CARD_STATUS_TONE as t } from "../../../shared/feature/dist/lib/card/cardPresentation.js";
3
3
  import "../../../shared/feature/dist/index.js";
4
- import { maskCardNumber as n } from "./index3.js";
4
+ import { formatVelocityControlAmount as n, maskCardNumber as r } from "./index3.js";
5
5
  //#region ../../libs/tesouro-embedded-components-react/card-details-widget/feature/dist/index4.js
6
- var r = {
6
+ var i = {
7
7
  Supported: "supported",
8
8
  Missing: "missing",
9
9
  Unsupported: "unsupported"
10
10
  };
11
- function i(t) {
12
- return t === e.Credit || t === e.Debit ? r.Supported : t == null ? r.Missing : r.Unsupported;
11
+ function a(t) {
12
+ return t === e.Credit || t === e.Debit ? i.Supported : t == null ? i.Missing : i.Unsupported;
13
13
  }
14
- function a({ programValidity: e, isNotFound: t, isError: n, hasCard: i }) {
15
- return e === r.Supported ? t ? "notFound" : i ? "loaded" : n ? "error" : "loading" : "error";
14
+ function o({ programValidity: e, isNotFound: t, isError: n, hasCard: r }) {
15
+ return e === i.Supported ? t ? "notFound" : r ? "loaded" : n ? "error" : "loading" : "error";
16
16
  }
17
- function o({ card: e, cardProgram: r, labels: i }) {
17
+ var s = "PENDING_ACTIVATION";
18
+ function c({ panelState: t, cardProgram: n, cardStatus: r }) {
19
+ return t !== "loaded" || n !== e.Debit || r === void 0 ? !1 : r !== s;
20
+ }
21
+ function l({ isRevealRequested: e, isError: t, hasCredentials: n }) {
22
+ return e ? t ? "errored" : n ? "revealed" : "revealing" : "hidden";
23
+ }
24
+ function u({ card: e, cardProgram: n, labels: i }) {
18
25
  let a = e.cardholderName.trim(), o = e.nickname?.trim();
19
26
  return {
20
27
  statusLabel: i.statusLabels[e.cardStatus],
21
28
  statusTone: t[e.cardStatus],
22
29
  formFactorLabel: i.formFactorLabels[e.cardType],
23
- programLabel: i.programLabels[r],
24
- maskedCardNumber: n(e.lastFourDigits),
30
+ programLabel: i.programLabels[n],
31
+ maskedCardNumber: r(e.lastFourDigits),
25
32
  cardholderName: a || void 0,
26
- nickname: o || void 0
33
+ nickname: o || void 0,
34
+ allowedCategories: d(e.mccGroups),
35
+ ...f(e.velocityControls, i)
36
+ };
37
+ }
38
+ function d(e) {
39
+ let t = (e ?? []).filter((e) => e.active).map((e) => e.name);
40
+ return t.length ? t : void 0;
41
+ }
42
+ function f(e, t) {
43
+ let r = (e ?? []).filter((e) => e.active && !e.mcc && !e.mccGroup), i = r.filter((e) => e.velocityWindow !== "TRANSACTION").map((e) => {
44
+ let r = n(e);
45
+ return r ? `${r} / ${t.velocityWindowLabels[e.velocityWindow]}` : void 0;
46
+ }).filter((e) => !!e), a = r.find((e) => e.velocityWindow === "TRANSACTION");
47
+ return {
48
+ spendLimitLabels: i.length ? i : void 0,
49
+ perTransactionMaxLabel: a ? n(a) : void 0
27
50
  };
28
51
  }
29
52
  //#endregion
30
- export { r as CardProgramValidity, a as resolveCardDetailsPanelState, o as resolveCardDetailsPresentation, i as resolveCardProgramValidity };
53
+ export { i as CardProgramValidity, c as resolveCanRevealCredentials, o as resolveCardDetailsPanelState, u as resolveCardDetailsPresentation, l as resolveCardDetailsRevealState, a as resolveCardProgramValidity };
@@ -4,12 +4,20 @@ import "../../../shared/feature/dist/index.js";
4
4
  //#region ../../libs/tesouro-embedded-components-react/card-details-widget/feature/dist/index5.js
5
5
  var r = {
6
6
  copySuccessToast: "Copied to clipboard",
7
+ revealNotPermittedDescription: "This card's details can't be shown for this session.",
7
8
  programLabels: {
8
9
  [e.Credit]: "Business credit",
9
10
  [e.Debit]: "Business debit"
10
11
  },
11
12
  statusLabels: t,
12
- formFactorLabels: n
13
+ formFactorLabels: n,
14
+ velocityWindowLabels: {
15
+ DAY: "day",
16
+ WEEK: "week",
17
+ MONTH: "month",
18
+ LIFETIME: "lifetime",
19
+ TRANSACTION: "transaction"
20
+ }
13
21
  };
14
22
  function i(e) {
15
23
  return {
@@ -26,6 +34,10 @@ function i(e) {
26
34
  formFactorLabels: {
27
35
  ...r.formFactorLabels,
28
36
  ...e?.formFactorLabels
37
+ },
38
+ velocityWindowLabels: {
39
+ ...r.velocityWindowLabels,
40
+ ...e?.velocityWindowLabels
29
41
  }
30
42
  };
31
43
  }
@@ -12,79 +12,138 @@ import { CardProgram as o } from "../../../shared/feature/dist/lib/card/cardProg
12
12
  import "../../../shared/feature/dist/index.js";
13
13
  import { resolveCardDetailsFeatureLabels as s } from "./index5.js";
14
14
  import { CardDetailsWidgetAnalyticsEvent as c, WIDGET_NAME as l } from "./index2.js";
15
- import { copyTextToClipboard as u } from "./index3.js";
16
- import { CardProgramValidity as d, resolveCardDetailsPanelState as f, resolveCardDetailsPresentation as p, resolveCardProgramValidity as m } from "./index4.js";
17
- import { useCreditCardDetailsQuery as h } from "../../data-access/dist/index4.js";
18
- import { useDebitCardDetailsQuery as g } from "../../data-access/dist/index5.js";
15
+ import { copyTextToClipboard as u, formatCardNumber as d, formatExpirationDate as f } from "./index3.js";
16
+ import { CardProgramValidity as p, resolveCanRevealCredentials as m, resolveCardDetailsPanelState as h, resolveCardDetailsPresentation as ee, resolveCardDetailsRevealState as te, resolveCardProgramValidity as g } from "./index4.js";
17
+ import { useCreditCardDetailsQuery as _ } from "../../data-access/dist/index4.js";
18
+ import { useDebitCardCredentialsQuery as v } from "../../data-access/dist/index5.js";
19
+ import { useDebitCardDetailsQuery as y } from "../../data-access/dist/index6.js";
19
20
  import "../../data-access/dist/index.js";
20
- import { CardDetailsPanel as _ } from "../../ui/dist/lib/CardDetailsPanel/CardDetailsPanel.js";
21
+ import { CardDetailsPanel as b } from "../../ui/dist/lib/CardDetailsPanel/CardDetailsPanel.js";
21
22
  import "../../ui/dist/index.js";
22
- import { useCallback as v, useEffect as y, useMemo as b } from "react";
23
- import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
23
+ import { useCallback as x, useEffect as S, useMemo as C, useState as ne } from "react";
24
+ import { Fragment as w, jsx as T, jsxs as re } from "react/jsx-runtime";
24
25
  //#region ../../libs/tesouro-embedded-components-react/card-details-widget/feature/dist/index6.js
25
- function w({ cardId: r, cardProgram: l, onClose: w, labels: T, featureLabels: E, bankLogoSrc: D, bankLogoAlt: O }) {
26
- let k = n(), A = a(), j = i();
27
- y(() => {
28
- k(c.Mounted);
29
- }, [k]);
30
- let M = b(() => s(E), [E]), N = m(l), P = l === o.Credit, F = l === o.Debit, I = h({
26
+ function E({ cardId: r, cardProgram: l, onClose: E, labels: D, featureLabels: O, bankLogoSrc: k, bankLogoAlt: A }) {
27
+ let j = n(), M = a(), N = i();
28
+ S(() => {
29
+ j(c.Mounted);
30
+ }, [j]);
31
+ let P = C(() => s(O), [O]), F = g(l), I = l === o.Credit, L = l === o.Debit, R = _({
31
32
  cardId: r,
32
- enabled: P
33
- }), L = g({
33
+ enabled: I
34
+ }), z = y({
34
35
  cardId: r,
35
- enabled: F
36
- }), { data: R, isError: z, isNotFound: B, refetch: V } = P ? I : L, H = f({
37
- programValidity: N,
38
- isNotFound: B,
39
- isError: !!A || z,
40
- hasCard: !!R
36
+ enabled: L
37
+ }), { data: B, isError: V, isNotFound: H, refetch: U } = I ? R : z, W = h({
38
+ programValidity: F,
39
+ isNotFound: H,
40
+ isError: !!M || V,
41
+ hasCard: !!B
41
42
  });
42
- y(() => {
43
- if (N === d.Supported) return;
43
+ S(() => {
44
+ if (F === p.Supported) return;
44
45
  let e = `"${o.Credit}" or "${o.Debit}"`;
45
- console.error(N === d.Missing ? `[CardDetailsWidget] cardProgram is required and was not set. Pass ${e} — it selects which card program to read, so there is no default. No card was fetched.` : `[CardDetailsWidget] cardProgram must be ${e}, received ${JSON.stringify(l)}. No card was fetched.`);
46
- }, [l, N]);
47
- let U = b(() => H === "loaded" && R ? p({
48
- card: R,
46
+ console.error(F === p.Missing ? `[CardDetailsWidget] cardProgram is required and was not set. Pass ${e} — it selects which card program to read, so there is no default. No card was fetched.` : `[CardDetailsWidget] cardProgram must be ${e}, received ${JSON.stringify(l)}. No card was fetched.`);
47
+ }, [l, F]);
48
+ let [G, K] = ne(), q = G === r;
49
+ S(() => {
50
+ K(void 0);
51
+ }, [r]);
52
+ let J = m({
53
+ panelState: W,
49
54
  cardProgram: l,
50
- labels: M
55
+ cardStatus: B?.cardStatus
56
+ });
57
+ S(() => {
58
+ q && !J && K(void 0);
59
+ }, [q, J]);
60
+ let Y = v({
61
+ cardId: r,
62
+ enabled: J && q
63
+ }), X = te({
64
+ isRevealRequested: q,
65
+ isError: Y.isError,
66
+ hasCredentials: !!Y.data
67
+ }), Z = C(() => W === "loaded" && B ? ee({
68
+ card: B,
69
+ cardProgram: l,
70
+ labels: P
51
71
  }) : void 0, [
52
- R,
72
+ B,
53
73
  l,
54
- M,
55
- H
56
- ]), W = v(async (t) => {
57
- await u(t) && (e.success(M.copySuccessToast), k(c.ValueCopied));
58
- }, [M.copySuccessToast, k]), G = v(() => {
59
- if (A) {
60
- j();
74
+ P,
75
+ W
76
+ ]), ie = x(async (t) => {
77
+ await u(t) && (e.success(P.copySuccessToast), j(c.ValueCopied));
78
+ }, [P.copySuccessToast, j]), { refetch: Q } = Y, ae = x(() => {
79
+ if (q) {
80
+ Q();
81
+ return;
82
+ }
83
+ K(r);
84
+ }, [
85
+ r,
86
+ q,
87
+ Q
88
+ ]), oe = x(() => {
89
+ K(void 0);
90
+ }, []), se = x(() => {
91
+ K(void 0), E?.();
92
+ }, [E]), ce = C(() => Y.isForbidden ? {
93
+ ...D,
94
+ credentials: {
95
+ ...D?.credentials,
96
+ errorDescription: P.revealNotPermittedDescription
97
+ }
98
+ } : D, [
99
+ Y.isForbidden,
100
+ D,
101
+ P.revealNotPermittedDescription
102
+ ]), $ = C(() => {
103
+ if (!(X !== "revealed" || !Y.data)) return {
104
+ cardNumber: d(Y.data.pan),
105
+ expirationDate: f(Y.data.expirationDate),
106
+ securityCode: Y.data.cvv
107
+ };
108
+ }, [Y.data, X]), le = x(() => {
109
+ if (M) {
110
+ N();
61
111
  return;
62
112
  }
63
- V();
113
+ U();
64
114
  }, [
65
- V,
66
- j,
67
- A
115
+ U,
116
+ N,
117
+ M
68
118
  ]);
69
- return /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ S(t, {}), /* @__PURE__ */ S(_, {
70
- labels: T,
71
- state: H,
72
- nickname: U?.nickname,
73
- statusLabel: U?.statusLabel,
74
- statusTone: U?.statusTone,
75
- formFactorLabel: U?.formFactorLabel,
76
- onClose: w,
77
- bankLogoSrc: D,
78
- bankLogoAlt: O,
79
- cardholderName: U?.cardholderName,
80
- maskedCardNumber: U?.maskedCardNumber,
81
- programLabel: U?.programLabel,
82
- onCopy: W,
83
- onRetry: N === d.Supported ? G : void 0
119
+ return /* @__PURE__ */ re(w, { children: [/* @__PURE__ */ T(t, {}), /* @__PURE__ */ T(b, {
120
+ labels: ce,
121
+ state: W,
122
+ nickname: Z?.nickname,
123
+ statusLabel: Z?.statusLabel,
124
+ statusTone: Z?.statusTone,
125
+ formFactorLabel: Z?.formFactorLabel,
126
+ onClose: E ? se : void 0,
127
+ bankLogoSrc: k,
128
+ bankLogoAlt: A,
129
+ cardholderName: Z?.cardholderName,
130
+ maskedCardNumber: Z?.maskedCardNumber,
131
+ programLabel: Z?.programLabel,
132
+ allowedCategories: Z?.allowedCategories,
133
+ spendLimitLabels: Z?.spendLimitLabels,
134
+ perTransactionMaxLabel: Z?.perTransactionMaxLabel,
135
+ onCopy: ie,
136
+ onViewCard: J ? ae : void 0,
137
+ onHideCard: J ? oe : void 0,
138
+ revealState: X,
139
+ revealedCardNumber: $?.cardNumber,
140
+ revealedExpirationDate: $?.expirationDate,
141
+ revealedSecurityCode: $?.securityCode,
142
+ onRetry: F === p.Supported ? le : void 0
84
143
  })] });
85
144
  }
86
- function T({ baseUrl: e, widgetToken: t, organizationId: n, configClient: i, gatewayRouting: a, linkComponent: o, implementation: s, uiFramework: c, errorFallback: u, onError: d, analytics: f, disclosuresAcceptance: p, providerLabels: m, ...h }) {
87
- return /* @__PURE__ */ S(r, {
145
+ function D({ baseUrl: e, widgetToken: t, organizationId: n, configClient: i, gatewayRouting: a, linkComponent: o, implementation: s, uiFramework: c, errorFallback: u, onError: d, analytics: f, disclosuresAcceptance: p, providerLabels: m, ...h }) {
146
+ return /* @__PURE__ */ T(r, {
88
147
  widgetName: l,
89
148
  baseUrl: e,
90
149
  widgetToken: t,
@@ -99,8 +158,8 @@ function T({ baseUrl: e, widgetToken: t, organizationId: n, configClient: i, gat
99
158
  analytics: f,
100
159
  disclosuresAcceptance: p,
101
160
  providerLabels: m,
102
- children: /* @__PURE__ */ S(w, { ...h })
161
+ children: /* @__PURE__ */ T(E, { ...h })
103
162
  });
104
163
  }
105
164
  //#endregion
106
- export { T as CardDetailsWidget, T as default };
165
+ export { D as CardDetailsWidget, D as default };