@tesouro/embedded-components-react 0.11.7 → 0.11.9

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/dist/core.d.ts CHANGED
@@ -18,6 +18,13 @@ interface WidgetTokenManager {
18
18
  start(): void;
19
19
  stop(): void;
20
20
  refresh(): Promise<void>;
21
+ /**
22
+ * Reports that the API rejected `widgetToken` with a 401. Refreshes once per
23
+ * rejected token, and backs off when a token this produced is rejected too.
24
+ * Ignored for a token other than the current one, while a refresh is in
25
+ * flight, and while stopped.
26
+ */
27
+ reportRejectedToken(widgetToken: string): Promise<void>;
21
28
  getState(): WidgetTokenState;
22
29
  subscribe(listener: () => void): () => void;
23
30
  }
package/dist/index.css CHANGED
@@ -5215,6 +5215,9 @@
5215
5215
  .ttw\:group-data-\[orientation\=horizontal\]\/tabs\:h-9:is(:where(.ttw\:group\/tabs)[data-orientation="horizontal"] *) {
5216
5216
  height: calc(var(--ttw-spacing) * 9);
5217
5217
  }
5218
+ .ttw\:group-data-\[orientation\=horizontal\]\/tabs\:min-h-8:is(:where(.ttw\:group\/tabs)[data-orientation="horizontal"] *) {
5219
+ min-height: calc(var(--ttw-spacing) * 8);
5220
+ }
5218
5221
  .ttw\:group-data-\[orientation\=vertical\]\/tabs\:h-fit:is(:where(.ttw\:group\/tabs)[data-orientation="vertical"] *) {
5219
5222
  height: fit-content;
5220
5223
  }
@@ -5269,6 +5272,9 @@
5269
5272
  font-size: var(--ttw-text-xs);
5270
5273
  line-height: var(--tw-leading, var(--ttw-text-xs--line-height));
5271
5274
  }
5275
+ .ttw\:group-data-\[state\=active\]\/tabs-trigger\:bg-muted:is(:where(.ttw\:group\/tabs-trigger)[data-state="active"] *) {
5276
+ background-color: var(--ttw-muted);
5277
+ }
5272
5278
  .ttw\:group-data-\[state\=active\]\/tabs-trigger\:bg-primary:is(:where(.ttw\:group\/tabs-trigger)[data-state="active"] *) {
5273
5279
  background-color: var(--ttw-primary);
5274
5280
  }
@@ -6359,15 +6365,15 @@
6359
6365
  :is(.ttw\:\*\:data-\[slot\=select-value\]\:gap-2 > *)[data-slot="select-value"] {
6360
6366
  gap: calc(var(--ttw-spacing) * 2);
6361
6367
  }
6368
+ .ttw\:data-\[state\=active\]\:bg-background[data-state="active"] {
6369
+ background-color: var(--ttw-background);
6370
+ }
6362
6371
  .ttw\:data-\[state\=active\]\:bg-primary\/10[data-state="active"] {
6363
6372
  background-color: var(--ttw-primary);
6364
6373
  @supports (color: color-mix(in lab, red, red)) {
6365
6374
  background-color: color-mix(in oklab, var(--ttw-primary) 10%, transparent);
6366
6375
  }
6367
6376
  }
6368
- .ttw\:data-\[state\=active\]\:bg-secondary[data-state="active"] {
6369
- background-color: var(--ttw-secondary);
6370
- }
6371
6377
  .ttw\:data-\[state\=active\]\:font-medium[data-state="active"] {
6372
6378
  --tw-font-weight: var(--ttw-font-weight-medium);
6373
6379
  font-weight: var(--ttw-font-weight-medium);
@@ -6378,8 +6384,9 @@
6378
6384
  .ttw\:data-\[state\=active\]\:text-primary[data-state="active"] {
6379
6385
  color: var(--ttw-primary);
6380
6386
  }
6381
- .ttw\:data-\[state\=active\]\:text-secondary-foreground[data-state="active"] {
6382
- color: var(--ttw-secondary-foreground);
6387
+ .ttw\:data-\[state\=active\]\:shadow-sm[data-state="active"] {
6388
+ --tw-shadow: 0 1px 3px 0 var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 1px 2px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
6389
+ box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
6383
6390
  }
6384
6391
  .ttw\:data-\[state\=active\]\:after\:opacity-100[data-state="active"]::after {
6385
6392
  content: var(--tw-content);
package/dist/index.d.ts CHANGED
@@ -1305,6 +1305,13 @@ interface WidgetTokenManager {
1305
1305
  start(): void;
1306
1306
  stop(): void;
1307
1307
  refresh(): Promise<void>;
1308
+ /**
1309
+ * Reports that the API rejected `widgetToken` with a 401. Refreshes once per
1310
+ * rejected token, and backs off when a token this produced is rejected too.
1311
+ * Ignored for a token other than the current one, while a refresh is in
1312
+ * flight, and while stopped.
1313
+ */
1314
+ reportRejectedToken(widgetToken: string): Promise<void>;
1308
1315
  getState(): WidgetTokenState;
1309
1316
  subscribe(listener: () => void): () => void;
1310
1317
  }
@@ -1016,6 +1016,13 @@ interface WidgetTokenManager {
1016
1016
  start(): void;
1017
1017
  stop(): void;
1018
1018
  refresh(): Promise<void>;
1019
+ /**
1020
+ * Reports that the API rejected `widgetToken` with a 401. Refreshes once per
1021
+ * rejected token, and backs off when a token this produced is rejected too.
1022
+ * Ignored for a token other than the current one, while a refresh is in
1023
+ * flight, and while stopped.
1024
+ */
1025
+ reportRejectedToken(widgetToken: string): Promise<void>;
1019
1026
  getState(): WidgetTokenState;
1020
1027
  subscribe(listener: () => void): () => void;
1021
1028
  }
@@ -3,55 +3,58 @@
3
3
  "use client";
4
4
  "use client";
5
5
  import { createClientSecretInstaller as e } from "../../../../data-access/dist/lib/scopedClientSecret.js";
6
- import { registerQueryClient as t, unregisterQueryClient as ee } from "../../../../data-access/dist/lib/clientRegistry.js";
7
- import { createEmbeddedClient as te } from "../../../../data-access/dist/lib/createEmbeddedClient.js";
8
- import { EmbedApiProvider as n } from "../../../../data-access/dist/lib/EmbedApiContext.js";
6
+ import { registerQueryClient as t, unregisterQueryClient as n } from "../../../../data-access/dist/lib/clientRegistry.js";
7
+ import { createEmbeddedClient as r } from "../../../../data-access/dist/lib/createEmbeddedClient.js";
8
+ import { EmbedApiProvider as i } from "../../../../data-access/dist/lib/EmbedApiContext.js";
9
9
  import "../../../../data-access/dist/index.js";
10
- import { resolveUIFramework as r } from "../../../../ui/dist/lib/UIContext/UIContext.js";
11
- import { UIProvider as ne } from "../../../../ui/dist/lib/UIContext/UIProvider.js";
12
- import { useDesignSystemEnsurer as re } from "../../../../ui/dist/lib/UIContext/uiRendererRegistry.js";
10
+ import { resolveUIFramework as a } from "../../../../ui/dist/lib/UIContext/UIContext.js";
11
+ import { UIProvider as ee } from "../../../../ui/dist/lib/UIContext/UIProvider.js";
12
+ import { useDesignSystemEnsurer as te } from "../../../../ui/dist/lib/UIContext/uiRendererRegistry.js";
13
13
  import "../../../../ui/dist/index.js";
14
- import { getGlobalSnapshot as i, subscribeToGlobal as ie } from "./globalStore.js";
15
- import { configureEmbeddedClient as ae } from "../analytics/client.js";
16
- import { generateCorrelationId as oe } from "../analytics/ids.js";
17
- import { WidgetContext as a } from "./WidgetContext.js";
18
- import { resolveOrgId as o, useAuthEpoch as s } from "./utils.js";
19
- import { useWidgetFetch as se } from "./useWidgetFetch.js";
20
- import { deriveOrganizationStatus as ce } from "./deriveOrganizationStatus.js";
21
- import { deriveWidgetInitState as le, useWidgetInitPublisher as ue } from "./useWidgetInitPublisher.js";
22
- import { useEffect as c, useMemo as l, useRef as u, useState as d, useSyncExternalStore as f } from "react";
23
- import { jsx as p } from "react/jsx-runtime";
24
- import { QueryClient as m, QueryClientProvider as de } from "@tanstack/react-query";
14
+ import { getGlobalSnapshot as o, subscribeToGlobal as ne } from "./globalStore.js";
15
+ import { configureEmbeddedClient as re } from "../analytics/client.js";
16
+ import { generateCorrelationId as ie } from "../analytics/ids.js";
17
+ import { WidgetContext as s } from "./WidgetContext.js";
18
+ import { resolveOrgId as c, useAuthEpoch as l } from "./utils.js";
19
+ import { useWidgetFetch as ae } from "./useWidgetFetch.js";
20
+ import { deriveOrganizationStatus as oe } from "./deriveOrganizationStatus.js";
21
+ import { deriveWidgetInitState as se, useWidgetInitPublisher as ce } from "./useWidgetInitPublisher.js";
22
+ import { useTokenRefreshRef as le } from "./useTokenRefreshRef.js";
23
+ import { useEffect as u, useMemo as d, useRef as f, useState as p, useSyncExternalStore as ue } from "react";
24
+ import { jsx as m } from "react/jsx-runtime";
25
+ import { QueryClient as de, QueryClientProvider as fe } from "@tanstack/react-query";
25
26
  // ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/RootWidgetProvider.js
26
27
  function h({ children: h, baseUrl: g, widgetToken: _, organizationId: v, configClient: y, gatewayRouting: b, linkComponent: x, uiFramework: S, analytics: C, unstable_initResponseOverride: w, disclosuresAcceptance: T, providerLabels: E }) {
27
- let D = f(ie, i, i), O = g ?? D.baseUrl, k = _ === void 0 ? D.widgetToken : _, A = v === void 0 ? D.organizationId : v, j = y ?? D.configClient, M = b ?? D.gatewayRouting, N = x ?? D.linkComponent, P = S ?? D.uiFramework, F = C !== !1, [I] = d(oe), L = u({
28
+ let D = ue(ne, o, o), O = g ?? D.baseUrl, k = _ === void 0 ? D.widgetToken : _, A = v === void 0 ? D.organizationId : v, j = y ?? D.configClient, M = b ?? D.gatewayRouting, N = x ?? D.linkComponent, P = S ?? D.uiFramework, F = C !== !1, [I] = p(ie), L = f({
28
29
  enabled: F,
29
30
  organizationId: A,
30
31
  rootCorrelationId: I
31
- }), [R] = d(() => new m({ defaultOptions: {
32
+ }), [R] = p(() => new de({ defaultOptions: {
32
33
  queries: {
33
34
  retry: !1,
34
35
  refetchOnWindowFocus: !1
35
36
  },
36
37
  mutations: { retry: !1 }
37
38
  } }));
38
- c(() => (t(R), () => ee(R)), [R]);
39
- let z = u(k);
39
+ u(() => (t(R), () => n(R)), [R]);
40
+ let z = f(k);
40
41
  z.current = k;
41
- let B = u(null), V = l(() => e(B), []), fe = s(k), H = l(() => {
42
- let e = ae(te(O), {
42
+ let B = le(), V = f(null), pe = d(() => e(V), []), me = l(k), H = d(() => {
43
+ let e = re(r(O), {
43
44
  tokenRef: z,
44
45
  analyticsContextRef: L,
45
- clientSecretRef: B,
46
- gatewayRouting: M
46
+ clientSecretRef: V,
47
+ gatewayRouting: M,
48
+ refreshTokenRef: B
47
49
  });
48
50
  return j ? j(e) : e;
49
51
  }, [
50
52
  O,
51
53
  j,
52
- M
54
+ M,
55
+ B
53
56
  ]);
54
- c(() => {
57
+ u(() => {
55
58
  if (!F || !("window" in globalThis)) return;
56
59
  let e = !1;
57
60
  return import("../analytics/install.js").then(({ ensureAnalyticsAdapterInstalled: t }) => {
@@ -60,11 +63,11 @@ function h({ children: h, baseUrl: g, widgetToken: _, organizationId: v, configC
60
63
  e = !0;
61
64
  };
62
65
  }, [F]);
63
- let U = re(r(P));
64
- c(() => {
66
+ let U = te(a(P));
67
+ u(() => {
65
68
  U && U().catch(() => {});
66
69
  }, [U]);
67
- let { result: pe, loading: W, error: G, initStaleForToken: me, initReplacementPending: K, refetch: q } = se(w ? null : H, k, L), J = k ? w ?? pe ?? void 0 : void 0, Y = !w && me, X = o(A, Y ? void 0 : J?.organizationId), he = ce({
70
+ let { result: he, loading: W, error: G, initStaleForToken: K, initReplacementPending: ge, refetch: q } = ae(w ? null : H, k, L), J = k ? w ?? he ?? void 0 : void 0, Y = !w && K, X = c(A, Y ? void 0 : J?.organizationId), _e = oe({
68
71
  organizationId: X,
69
72
  cascadeOrgId: A,
70
73
  ownsFetch: !0,
@@ -73,8 +76,8 @@ function h({ children: h, baseUrl: g, widgetToken: _, organizationId: v, configC
73
76
  loading: W,
74
77
  error: G,
75
78
  hasResult: !!J,
76
- initReplacementPending: K
77
- }), ge = l(() => le({
79
+ initReplacementPending: ge
80
+ }), ve = d(() => se({
78
81
  hasToken: !!k,
79
82
  loading: W,
80
83
  error: G,
@@ -87,8 +90,8 @@ function h({ children: h, baseUrl: g, widgetToken: _, organizationId: v, configC
87
90
  J,
88
91
  Y
89
92
  ]);
90
- ue(ge, k);
91
- let Z = l(() => ({
93
+ ce(ve, k);
94
+ let Z = d(() => ({
92
95
  enabled: F,
93
96
  organizationId: X,
94
97
  rootCorrelationId: I
@@ -98,7 +101,7 @@ function h({ children: h, baseUrl: g, widgetToken: _, organizationId: v, configC
98
101
  I
99
102
  ]);
100
103
  L.current = Z;
101
- let Q = l(() => ({
104
+ let Q = d(() => ({
102
105
  baseUrl: g,
103
106
  widgetToken: _,
104
107
  organizationId: v,
@@ -114,7 +117,7 @@ function h({ children: h, baseUrl: g, widgetToken: _, organizationId: v, configC
114
117
  b,
115
118
  x,
116
119
  S
117
- ]), $ = l(() => ({
120
+ ]), $ = d(() => ({
118
121
  baseUrl: O,
119
122
  widgetToken: k,
120
123
  organizationId: X,
@@ -132,7 +135,7 @@ function h({ children: h, baseUrl: g, widgetToken: _, organizationId: v, configC
132
135
  N,
133
136
  P,
134
137
  J
135
- ]), _e = l(() => ({
138
+ ]), ye = d(() => ({
136
139
  resolved: $,
137
140
  own: Q,
138
141
  refetch: q,
@@ -155,18 +158,18 @@ function h({ children: h, baseUrl: g, widgetToken: _, organizationId: v, configC
155
158
  T,
156
159
  E
157
160
  ]);
158
- return /* @__PURE__ */ p(de, {
161
+ return /* @__PURE__ */ m(fe, {
159
162
  client: R,
160
- children: /* @__PURE__ */ p(n, {
163
+ children: /* @__PURE__ */ m(i, {
161
164
  client: H,
162
165
  organizationId: X,
163
166
  widgetToken: k,
164
- installClientSecret: V,
165
- authEpoch: fe,
166
- organizationStatus: he,
167
- children: /* @__PURE__ */ p(a.Provider, {
168
- value: _e,
169
- children: /* @__PURE__ */ p(ne, {
167
+ installClientSecret: pe,
168
+ authEpoch: me,
169
+ organizationStatus: _e,
170
+ children: /* @__PURE__ */ m(s.Provider, {
171
+ value: ye,
172
+ children: /* @__PURE__ */ m(ee, {
170
173
  linkComponent: N,
171
174
  uiFramework: P,
172
175
  children: h
@@ -24,94 +24,97 @@ import { noop as le, resolveOrgId as ue, useAuthEpoch as de } from "./utils.js";
24
24
  import { useWidgetFetch as fe } from "./useWidgetFetch.js";
25
25
  import { deriveOrganizationStatus as pe } from "./deriveOrganizationStatus.js";
26
26
  import { deriveWidgetInitState as me, useWidgetInitPublisher as he } from "./useWidgetInitPublisher.js";
27
+ import { useTokenRefreshRef as ge } from "./useTokenRefreshRef.js";
27
28
  import { useAnalyticsTrack as u } from "../analytics/hooks.js";
28
- import { resolveProviderLabels as ge } from "./labels.js";
29
- import { WidgetErrorBoundary as _e } from "./WidgetErrorBoundary.js";
30
- import { DISCLOSURES_REQUIRED_TEST_ID as d, hasRenderableAcceptanceSurface as f, resolveDisclosuresBlockedReason as p, shouldGateOnDisclosuresAcceptance as ve } from "./isDisclosuresAcceptanceRequired.js";
31
- import { useContext as ye, useEffect as m, useMemo as h, useRef as g, useState as _, useSyncExternalStore as be } from "react";
29
+ import { resolveProviderLabels as _e } from "./labels.js";
30
+ import { WidgetErrorBoundary as ve } from "./WidgetErrorBoundary.js";
31
+ import { DISCLOSURES_REQUIRED_TEST_ID as d, hasRenderableAcceptanceSurface as f, resolveDisclosuresBlockedReason as p, shouldGateOnDisclosuresAcceptance as ye } from "./isDisclosuresAcceptanceRequired.js";
32
+ import { useContext as be, useEffect as m, useMemo as h, useRef as g, useState as _, useSyncExternalStore as xe } from "react";
32
33
  import { jsx as v } from "react/jsx-runtime";
33
- import { QueryClient as xe, QueryClientProvider as Se } from "@tanstack/react-query";
34
+ import { QueryClient as Se, QueryClientProvider as Ce } from "@tanstack/react-query";
34
35
  // ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/WidgetProvider.js
35
- function y({ children: re, baseUrl: s, widgetToken: c, organizationId: u, configClient: d, gatewayRouting: f, linkComponent: p, uiFramework: y, errorFallback: we, onError: Te, analytics: b, disclosuresAcceptance: Ee, providerLabels: De, widgetName: x }) {
36
+ function y({ children: re, baseUrl: s, widgetToken: c, organizationId: u, configClient: d, gatewayRouting: f, linkComponent: p, uiFramework: y, errorFallback: Te, onError: Ee, analytics: b, disclosuresAcceptance: De, providerLabels: Oe, widgetName: x }) {
36
37
  e();
37
- let S = ye(l), Oe = be(oe, ae, ae), C = S?.resolved ?? Oe, ke = S?.refetch ?? le, Ae = S?.loading ?? !1, je = S?.error ?? null, w = s ?? C.baseUrl, T = c === void 0 ? C.widgetToken : c, Me = S ? S.cascadeOrgId : Oe.organizationId, E = u === void 0 ? Me : u, D = d ?? C.configClient, O = f ?? C.gatewayRouting, k = p ?? C.linkComponent, A = y ?? C.uiFramework, j = Ee ?? S?.disclosuresAcceptance, M = De ?? S?.providerLabels, Ne = h(() => ge(M), [M]), N = S === null, P = N ? b !== !1 : S.analytics.enabled, [Pe] = _(ce), F = N ? Pe : S.analytics.rootCorrelationId, [Fe] = _(ce), I = x === void 0 ? S?.analytics.widgetName : x, L = x === void 0 ? S?.analytics.widgetInstanceId : Fe, R = g({
38
- enabled: P,
39
- organizationId: E,
40
- rootCorrelationId: F,
41
- widgetName: I,
42
- widgetInstanceId: L
43
- }), Ie = g(!1);
38
+ let S = be(l), C = xe(oe, ae, ae), w = S?.resolved ?? C, ke = S?.refetch ?? le, Ae = S?.loading ?? !1, je = S?.error ?? null, T = s ?? w.baseUrl, E = c === void 0 ? w.widgetToken : c, Me = S ? S.cascadeOrgId : C.organizationId, D = u === void 0 ? Me : u, O = d ?? w.configClient, k = f ?? w.gatewayRouting, A = p ?? w.linkComponent, j = y ?? w.uiFramework, M = De ?? S?.disclosuresAcceptance, N = Oe ?? S?.providerLabels, P = h(() => _e(N), [N]), F = S === null, I = F ? b !== !1 : S.analytics.enabled, [Ne] = _(ce), L = F ? Ne : S.analytics.rootCorrelationId, [Pe] = _(ce), R = x === void 0 ? S?.analytics.widgetName : x, z = x === void 0 ? S?.analytics.widgetInstanceId : Pe, B = g({
39
+ enabled: I,
40
+ organizationId: D,
41
+ rootCorrelationId: L,
42
+ widgetName: R,
43
+ widgetInstanceId: z
44
+ }), Fe = g(!1);
44
45
  m(() => {
45
- N || b === void 0 || Ie.current || (Ie.current = !0, console.warn("[tesouro-embedded] `analytics` on a nested WidgetProvider is ignored in v1. Set it on the outermost RootWidgetProvider or standalone WidgetProvider instead."));
46
- }, [b, N]), m(() => {
47
- if (!N || !P || !("window" in globalThis)) return;
46
+ F || b === void 0 || Fe.current || (Fe.current = !0, console.warn("[tesouro-embedded] `analytics` on a nested WidgetProvider is ignored in v1. Set it on the outermost RootWidgetProvider or standalone WidgetProvider instead."));
47
+ }, [b, F]), m(() => {
48
+ if (!F || !I || !("window" in globalThis)) return;
48
49
  let e = !1;
49
50
  return import("../analytics/install.js").then(({ ensureAnalyticsAdapterInstalled: t }) => {
50
51
  e || t();
51
52
  }), () => {
52
53
  e = !0;
53
54
  };
54
- }, [N, P]);
55
- let z = ne(ee(A));
55
+ }, [F, I]);
56
+ let V = ne(ee(j));
56
57
  m(() => {
57
- z && z().catch(() => {});
58
- }, [z]);
59
- let B = S === null || s !== void 0 || c !== void 0 || u !== void 0 || d != null || f !== void 0 || x !== void 0, V = g(T);
60
- V.current = T;
61
- let H = g(null), Le = h(() => t(H), []), Re = o(), ze = de(T), U = h(() => {
62
- if (!B) return null;
63
- let e = se(i(w), {
64
- tokenRef: V,
65
- analyticsContextRef: R,
66
- clientSecretRef: H,
67
- gatewayRouting: O
58
+ V && V().catch(() => {});
59
+ }, [V]);
60
+ let Ie = S === null || s !== void 0 || c !== void 0 || u !== void 0 || d != null || f !== void 0 || x !== void 0, Le = g(E);
61
+ Le.current = E;
62
+ let Re = ge(), ze = g(null), Be = h(() => t(ze), []), Ve = o(), He = de(E), H = h(() => {
63
+ if (!Ie) return null;
64
+ let e = se(i(T), {
65
+ tokenRef: Le,
66
+ analyticsContextRef: B,
67
+ clientSecretRef: ze,
68
+ gatewayRouting: k,
69
+ refreshTokenRef: Re
68
70
  });
69
- return D ? D(e) : e;
71
+ return O ? O(e) : e;
70
72
  }, [
71
- B,
72
- w,
73
- D,
74
- O
75
- ]), W = S === null || s !== void 0 || c !== void 0, Be = W ? ze : Re.authEpoch, { result: G, loading: K, error: q, clearedForAuthChange: Ve, initStaleForToken: J, initReplacementPending: He, refetch: Ue } = fe(W ? U : null, W ? T : void 0, R), We = W ? Ue : ke, Ge = W ? K : Ae, Ke = W ? q : je, qe = S?.resolved.initResponse, Je = !W || !Ve && !q && !G && !!T && !K, Y = Je ? qe : G ?? void 0, X = Je ? W || (S?.initResponseStaleForToken ?? !1) : J, Ye = S === null, Xe = h(() => Ye ? me({
76
- hasToken: !!T,
77
- loading: K,
78
- error: q,
79
- initResponse: G ?? void 0,
80
- initStaleForToken: J
81
- }) : null, [
82
- Ye,
73
+ Ie,
83
74
  T,
84
- K,
85
- q,
75
+ O,
76
+ k,
77
+ Re
78
+ ]), U = S === null || s !== void 0 || c !== void 0, Ue = U ? He : Ve.authEpoch, { result: W, loading: G, error: K, clearedForAuthChange: We, initStaleForToken: q, initReplacementPending: Ge, refetch: Ke } = fe(U ? H : null, U ? E : void 0, B), qe = U ? Ke : ke, Je = U ? G : Ae, Ye = U ? K : je, Xe = S?.resolved.initResponse, J = !U || !We && !K && !W && !!E && !G, Y = J ? Xe : W ?? void 0, X = J ? U || (S?.initResponseStaleForToken ?? !1) : q, Ze = S === null, Qe = h(() => Ze ? me({
79
+ hasToken: !!E,
80
+ loading: G,
81
+ error: K,
82
+ initResponse: W ?? void 0,
83
+ initStaleForToken: q
84
+ }) : null, [
85
+ Ze,
86
+ E,
86
87
  G,
87
- J
88
+ K,
89
+ W,
90
+ q
88
91
  ]);
89
- he(Xe, T);
90
- let Z = ue(E, X ? void 0 : Y?.organizationId), Ze = pe({
92
+ he(Qe, E);
93
+ let Z = ue(D, X ? void 0 : Y?.organizationId), $e = pe({
91
94
  organizationId: Z,
92
- cascadeOrgId: E,
93
- ownsFetch: W,
94
- parentStatus: Re.organizationStatus,
95
- hasToken: !!T,
96
- loading: K,
97
- error: q,
98
- hasResult: !!G,
99
- initReplacementPending: He
95
+ cascadeOrgId: D,
96
+ ownsFetch: U,
97
+ parentStatus: Ve.organizationStatus,
98
+ hasToken: !!E,
99
+ loading: G,
100
+ error: K,
101
+ hasResult: !!W,
102
+ initReplacementPending: Ge
100
103
  }), Q = h(() => ({
101
- enabled: P,
104
+ enabled: I,
102
105
  organizationId: Z,
103
- rootCorrelationId: F,
104
- widgetName: I,
105
- widgetInstanceId: L
106
+ rootCorrelationId: L,
107
+ widgetName: R,
108
+ widgetInstanceId: z
106
109
  }), [
107
- P,
108
- Z,
109
- F,
110
110
  I,
111
- L
111
+ Z,
112
+ L,
113
+ R,
114
+ z
112
115
  ]);
113
- R.current = Q;
114
- let [$] = _(() => S === null ? new xe({ defaultOptions: {
116
+ B.current = Q;
117
+ let [$] = _(() => S === null ? new Se({ defaultOptions: {
115
118
  queries: {
116
119
  retry: !1,
117
120
  refetchOnWindowFocus: !1
@@ -123,7 +126,7 @@ function y({ children: re, baseUrl: s, widgetToken: c, organizationId: u, config
123
126
  let e = $;
124
127
  return n(e), () => r(e);
125
128
  }, [$]);
126
- let Qe = h(() => ({
129
+ let et = h(() => ({
127
130
  baseUrl: s,
128
131
  widgetToken: c,
129
132
  organizationId: u,
@@ -139,78 +142,78 @@ function y({ children: re, baseUrl: s, widgetToken: c, organizationId: u, config
139
142
  f,
140
143
  p,
141
144
  y
142
- ]), $e = h(() => ({
143
- baseUrl: w,
144
- widgetToken: T,
145
+ ]), tt = h(() => ({
146
+ baseUrl: T,
147
+ widgetToken: E,
145
148
  organizationId: Z,
146
- configClient: D,
147
- gatewayRouting: O,
148
- linkComponent: k,
149
- uiFramework: A,
149
+ configClient: O,
150
+ gatewayRouting: k,
151
+ linkComponent: A,
152
+ uiFramework: j,
150
153
  initResponse: Y
151
154
  }), [
152
- w,
153
155
  T,
156
+ E,
154
157
  Z,
155
- D,
156
158
  O,
157
159
  k,
158
160
  A,
161
+ j,
159
162
  Y
160
- ]), et = h(() => ({
161
- resolved: $e,
162
- own: Qe,
163
- refetch: We,
164
- loading: Ge,
165
- error: Ke,
163
+ ]), nt = h(() => ({
164
+ resolved: tt,
165
+ own: et,
166
+ refetch: qe,
167
+ loading: Je,
168
+ error: Ye,
166
169
  analytics: Q,
167
- cascadeOrgId: E,
170
+ cascadeOrgId: D,
168
171
  initResponseStaleForToken: X,
169
- disclosuresAcceptance: j,
170
- providerLabels: M
172
+ disclosuresAcceptance: M,
173
+ providerLabels: N
171
174
  }), [
172
- $e,
173
- Qe,
174
- We,
175
- Ge,
176
- Ke,
175
+ tt,
176
+ et,
177
+ qe,
178
+ Je,
179
+ Ye,
177
180
  Q,
178
- E,
181
+ D,
179
182
  X,
180
- j,
181
- M
182
- ]), tt = /* @__PURE__ */ v(l.Provider, {
183
- value: et,
183
+ M,
184
+ N
185
+ ]), rt = /* @__PURE__ */ v(l.Provider, {
186
+ value: nt,
184
187
  children: /* @__PURE__ */ v(te, {
185
- linkComponent: k,
186
- uiFramework: A,
187
- children: /* @__PURE__ */ v(ie, { children: /* @__PURE__ */ v(_e, {
188
- resetKeys: [T],
189
- errorFallback: we,
190
- onError: Te,
191
- labels: Ne,
192
- children: ve(Y, x) ? /* @__PURE__ */ v(Ce, {
193
- disclosuresAcceptance: j,
188
+ linkComponent: A,
189
+ uiFramework: j,
190
+ children: /* @__PURE__ */ v(ie, { children: /* @__PURE__ */ v(ve, {
191
+ resetKeys: [E],
192
+ errorFallback: Te,
193
+ onError: Ee,
194
+ labels: P,
195
+ children: ye(Y, x) ? /* @__PURE__ */ v(we, {
196
+ disclosuresAcceptance: M,
194
197
  initStaleForToken: X,
195
- labels: Ne
198
+ labels: P
196
199
  }) : re
197
200
  }) })
198
201
  })
199
- }), nt = U ? /* @__PURE__ */ v(a, {
200
- client: U,
202
+ }), it = H ? /* @__PURE__ */ v(a, {
203
+ client: H,
201
204
  organizationId: Z,
202
- widgetToken: T,
203
- installClientSecret: Le,
204
- authEpoch: Be,
205
- organizationStatus: Ze,
206
- children: tt
207
- }) : tt;
208
- return $ ? /* @__PURE__ */ v(Se, {
205
+ widgetToken: E,
206
+ installClientSecret: Be,
207
+ authEpoch: Ue,
208
+ organizationStatus: $e,
209
+ children: rt
210
+ }) : rt;
211
+ return $ ? /* @__PURE__ */ v(Ce, {
209
212
  client: $,
210
- children: nt
211
- }) : nt;
213
+ children: it
214
+ }) : it;
212
215
  }
213
- function Ce({ disclosuresAcceptance: e, initStaleForToken: t, labels: n }) {
216
+ function we({ disclosuresAcceptance: e, initStaleForToken: t, labels: n }) {
214
217
  let r = re("error-state") ?? s, i = u(), a = f(e), o = p({
215
218
  initStaleForToken: t,
216
219
  hasAcceptanceSurface: a
@@ -0,0 +1,8 @@
1
+ import { WidgetTokenRefreshContext as e } from "./WidgetTokenRefreshContext.js";
2
+ import { useContext as t, useRef as n } from "react";
3
+ // ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/useTokenRefreshRef.js
4
+ function r() {
5
+ let r = t(e), i = n(null);
6
+ return i.current = r ? (e) => void r.reportRejectedToken(e) : null, i;
7
+ }
8
+ export { r as useTokenRefreshRef };
@@ -1,5 +1,5 @@
1
1
  // ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
2
- var e = "@tesouro/embedded-components-react", t = "0.11.7", n = "847cfd88f43c0f8334faca85a736783acbf48fd1", r = Object.freeze({
2
+ var e = "@tesouro/embedded-components-react", t = "0.11.9", n = "bfb00e0822787c75eaf1f5aca4766310de2aff82", r = Object.freeze({
3
3
  library_name: e,
4
4
  library_version: t,
5
5
  library_sha: n
@@ -1,12 +1,15 @@
1
1
  import { attachTransportInterceptors as e } from "../../../../data-access/dist/lib/transportInterceptors.js";
2
2
  import "../../../../data-access/dist/index.js";
3
- import { attachAnalyticsInterceptors as t } from "./interceptor.js";
3
+ import { attachAnalyticsInterceptors as t, tokenCarriedBy as n } from "./interceptor.js";
4
4
  // ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/client.js
5
- function n(n, { tokenRef: r, analyticsContextRef: i, clientSecretRef: a, gatewayRouting: o }) {
6
- return e(n, {
7
- tokenRef: r,
8
- clientSecretRef: a,
9
- gatewayRouting: o
10
- }), t(n, i), n;
5
+ function r(r, { tokenRef: i, analyticsContextRef: a, clientSecretRef: o, gatewayRouting: s, refreshTokenRef: c }) {
6
+ return e(r, {
7
+ tokenRef: i,
8
+ clientSecretRef: o,
9
+ gatewayRouting: s
10
+ }), c && r.interceptors.error.use((e, t, r) => {
11
+ let a = n(r);
12
+ return t?.status === 401 && a && a === i.current && c.current?.(a), e;
13
+ }), t(r, a), r;
11
14
  }
12
- export { n as configureEmbeddedClient };
15
+ export { r as configureEmbeddedClient };
@@ -3,7 +3,8 @@ var e = /* @__PURE__ */ new Set([
3
3
  "GET /identity/v1/user-data/{key}",
4
4
  "GET /embedded-banking/v1/credit-cards/{cardId}",
5
5
  "GET /embedded-banking/v1/debit-cards/{cardId}",
6
- "GET /finops/v1/payables/{payable_id}/suggestions"
6
+ "GET /finops/v1/payables/{payable_id}/suggestions",
7
+ "GET /identity/v1/financial_institution"
7
8
  ]);
8
9
  function t(t, n, r) {
9
10
  return t === 404 && n !== void 0 && r !== void 0 && e.has(`${n.toUpperCase()} ${r}`);
@@ -66,4 +66,4 @@ function p() {
66
66
  function m(e) {
67
67
  return e === void 0 ? void 0 : Math.round(p() - e);
68
68
  }
69
- export { l as attachAnalyticsInterceptors };
69
+ export { l as attachAnalyticsInterceptors, d as tokenCarriedBy };
@@ -1,89 +1,101 @@
1
1
  // ../../libs/tesouro-embedded-components-react/shared/util/dist/lib/widgetTokenManager.js
2
- function e(e) {
3
- let { fetcher: t } = e, n = e.leadSeconds ?? 60, r = { status: "loading" }, i = /* @__PURE__ */ new Set(), a = 0, o = 0, s = 0, c = !1, l = !1, u = !1, d, f, p, m = () => {
4
- i.forEach((e) => e());
5
- }, h = (e) => {
6
- r = e, m();
7
- }, g = () => {
8
- d !== void 0 && (clearTimeout(d), d = void 0), f !== void 0 && (clearTimeout(f), f = void 0), p !== void 0 && (clearTimeout(p), p = void 0);
9
- }, _ = (e) => {
10
- let t = Math.max(0, e * 1e3 - Date.now() - n * 1e3);
11
- d = setTimeout(() => {
12
- d = void 0, b({ manual: !1 });
2
+ var e = 3e4, t = 3e5;
3
+ function n(n) {
4
+ let { fetcher: r } = n, i = n.leadSeconds ?? 60, a = { status: "loading" }, o = /* @__PURE__ */ new Set(), s = 0, c = 0, l = 0, u = !1, d = !1, f = !1, p, m, h, g, _ = null, v = null, y = 0, b = 0, x = () => {
5
+ o.forEach((e) => e());
6
+ }, S = (e) => {
7
+ a = e, x();
8
+ }, C = () => {
9
+ p !== void 0 && (clearTimeout(p), p = void 0), m !== void 0 && (clearTimeout(m), m = void 0), h !== void 0 && (clearTimeout(h), h = void 0);
10
+ }, w = (e) => {
11
+ let t = Math.max(0, e * 1e3 - Date.now() - i * 1e3);
12
+ p = setTimeout(() => {
13
+ p = void 0, D({ manual: !1 });
13
14
  }, t);
14
- }, v = (e) => {
15
+ }, T = (e) => {
15
16
  let t = Math.max(0, e * 1e3 - Date.now());
16
- p = setTimeout(() => {
17
- p = void 0, r.status === "ready" && r.lastError !== void 0 && h({
17
+ h = setTimeout(() => {
18
+ h = void 0, a.status === "ready" && a.lastError !== void 0 && S({
18
19
  status: "error",
19
- error: r.lastError
20
+ error: a.lastError
20
21
  });
21
22
  }, t);
22
- }, y = async ({ manual: e, gen: n, myId: i }) => {
23
- g();
24
- let c = r;
25
- c.status === "ready" && h({
26
- ...c,
23
+ }, E = async ({ manual: e, gen: t, myId: n }) => {
24
+ C();
25
+ let i = a;
26
+ i.status === "ready" && S({
27
+ ...i,
27
28
  isRefreshing: !0
28
29
  });
29
- let l, u, d = !1;
30
+ let o, u, d = !1;
30
31
  try {
31
- l = await t();
32
+ o = await r();
32
33
  } catch (e) {
33
34
  d = !0, u = e;
34
35
  }
35
- if (n !== a || i !== o) return;
36
- if (!d && l !== void 0 && l.exp !== void 0 && l.exp * 1e3 <= Date.now() && (d = !0, u = /* @__PURE__ */ Error("Fetched widget token is already expired")), !d && l !== void 0) {
37
- h({
36
+ if (t !== s || n !== c) return;
37
+ if (!d && o !== void 0 && o.exp !== void 0 && o.exp * 1e3 <= Date.now() && (d = !0, u = /* @__PURE__ */ Error("Fetched widget token is already expired")), !d && o !== void 0) {
38
+ S({
38
39
  status: "ready",
39
- widgetToken: l.widgetToken,
40
- exp: l.exp,
40
+ widgetToken: o.widgetToken,
41
+ exp: o.exp,
41
42
  isRefreshing: !1
42
- }), s = 0, l.exp !== void 0 && _(l.exp);
43
+ }), l = 0, o.exp !== void 0 && w(o.exp);
43
44
  return;
44
45
  }
45
- c.status === "ready" && (c.exp === void 0 || c.exp * 1e3 > Date.now()) ? (h({
46
+ i.status === "ready" && (i.exp === void 0 || i.exp * 1e3 > Date.now()) ? (S({
46
47
  status: "ready",
47
- widgetToken: c.widgetToken,
48
- exp: c.exp,
48
+ widgetToken: i.widgetToken,
49
+ exp: i.exp,
49
50
  isRefreshing: !1,
50
51
  lastError: u
51
- }), c.exp !== void 0 && v(c.exp)) : h({
52
+ }), i.exp !== void 0 && T(i.exp)) : S({
52
53
  status: "error",
53
54
  error: u
54
55
  });
55
- let p = Math.max(50, Math.random() * Math.min(3e4, 1e3 * 2 ** s));
56
- s++, f = setTimeout(() => {
57
- f = void 0, b({ manual: !1 });
58
- }, p);
59
- }, b = ({ manual: e }) => {
60
- let t = a, n = ++o;
61
- return u = !0, y({
56
+ let f = Math.max(50, Math.random() * Math.min(3e4, 1e3 * 2 ** l));
57
+ l++, m = setTimeout(() => {
58
+ m = void 0, D({ manual: !1 });
59
+ }, f);
60
+ }, D = ({ manual: e }) => {
61
+ let t = s, n = ++c;
62
+ return f = !0, E({
62
63
  manual: e,
63
64
  gen: t,
64
65
  myId: n
65
66
  }).finally(() => {
66
- n === o && (u = !1);
67
+ n === c && (f = !1);
67
68
  });
68
- }, x = (e) => {
69
- (e.type !== "visibilitychange" || document.visibilityState === "visible") && c && !u && r.status !== "loading" && (r.status === "error" || !r.isRefreshing && r.exp !== void 0 && r.exp * 1e3 - Date.now() < n * 1e3) && b({ manual: !1 });
70
- }, S = () => {
71
- l || typeof window > "u" || typeof document > "u" || (l = !0, document.addEventListener("visibilitychange", x), window.addEventListener("focus", x), window.addEventListener("online", x));
72
- }, C = () => {
73
- l && (l = !1, document.removeEventListener("visibilitychange", x), window.removeEventListener("focus", x), window.removeEventListener("online", x));
69
+ }, O = (e) => {
70
+ (e.type !== "visibilitychange" || document.visibilityState === "visible") && u && !f && a.status !== "loading" && (a.status === "error" || !a.isRefreshing && a.exp !== void 0 && a.exp * 1e3 - Date.now() < i * 1e3) && D({ manual: !1 });
71
+ }, k = () => {
72
+ d || typeof window > "u" || typeof document > "u" || (d = !0, document.addEventListener("visibilitychange", O), window.addEventListener("focus", O), window.addEventListener("online", O));
73
+ }, A = () => {
74
+ d && (d = !1, document.removeEventListener("visibilitychange", O), window.removeEventListener("focus", O), window.removeEventListener("online", O));
75
+ }, j = () => {
76
+ g !== void 0 && (clearTimeout(g), g = void 0);
77
+ }, M = (n) => {
78
+ if (!u || a.status !== "ready" || a.widgetToken !== n || a.isRefreshing || _ === n) return Promise.resolve();
79
+ let r = n === v ? y + 1 : 0, i = r === 0 ? 0 : Math.min(e * 2 ** (r - 1), t), o = Date.now(), s = i - (o - b);
80
+ return j(), s > 0 ? (g = setTimeout(() => {
81
+ g = void 0, M(n);
82
+ }, s), Promise.resolve()) : (_ = n, y = r, b = o, D({ manual: !0 }).finally(() => {
83
+ a.status === "ready" ? (v = a.widgetToken, a.widgetToken === n && (_ = null)) : v = null;
84
+ }));
74
85
  };
75
86
  return {
76
87
  start: () => {
77
- c || (c = !0, S(), b({ manual: !1 }));
88
+ u || (u = !0, k(), D({ manual: !1 }));
78
89
  },
79
90
  stop: () => {
80
- c = !1, a++, g(), C();
91
+ u = !1, s++, C(), j(), A();
81
92
  },
82
- refresh: () => (c = !0, S(), b({ manual: !0 })),
83
- getState: () => r,
84
- subscribe: (e) => (i.add(e), () => {
85
- i.delete(e);
93
+ refresh: () => (u = !0, k(), D({ manual: !0 })),
94
+ reportRejectedToken: M,
95
+ getState: () => a,
96
+ subscribe: (e) => (o.add(e), () => {
97
+ o.delete(e);
86
98
  })
87
99
  };
88
100
  }
89
- export { e as createWidgetTokenManager };
101
+ export { t as MAX_REJECTED_REFRESH_BACKOFF_MS, e as REJECTED_REFRESH_BACKOFF_MS, n as createWidgetTokenManager };
@@ -10460,7 +10460,7 @@ var Jx = Wv([
10460
10460
  ], {
10461
10461
  variants: { variant: {
10462
10462
  underline: "ttw:gap-4 ttw:group-data-[orientation=horizontal]/tabs:h-9 ttw:group-data-[orientation=vertical]/tabs:gap-1",
10463
- pills: "ttw:gap-2"
10463
+ pills: "ttw:gap-2 ttw:rounded-lg ttw:bg-muted ttw:p-1 ttw:group-data-[orientation=horizontal]/tabs:min-h-8"
10464
10464
  } },
10465
10465
  defaultVariants: { variant: "underline" }
10466
10466
  }), Yx = e.createContext("underline");
@@ -10491,15 +10491,14 @@ var Zx = Wv([
10491
10491
  "ttw:group-data-[orientation=vertical]/tabs:after:inset-y-0 ttw:group-data-[orientation=vertical]/tabs:after:left-0 ttw:group-data-[orientation=vertical]/tabs:after:w-0.5",
10492
10492
  "ttw:group-data-[orientation=vertical]/tabs:py-1.5 ttw:group-data-[orientation=vertical]/tabs:pl-3"
10493
10493
  ],
10494
- pills: [
10495
- "ttw:h-8 ttw:rounded-full ttw:px-3",
10496
- "ttw:hover:bg-accent ttw:hover:text-accent-foreground",
10497
- "ttw:data-[state=active]:bg-secondary ttw:data-[state=active]:text-secondary-foreground"
10498
- ]
10494
+ pills: ["ttw:h-6 ttw:rounded-md ttw:px-2 ttw:hover:text-foreground", "ttw:data-[state=active]:bg-background ttw:data-[state=active]:text-foreground ttw:data-[state=active]:shadow-sm"]
10499
10495
  } },
10500
10496
  defaultVariants: { variant: "underline" }
10501
10497
  }), Qx = "ttw:inline-flex ttw:h-5 ttw:min-w-5 ttw:items-center ttw:justify-center ttw:rounded-full ttw:px-1.5 ttw:text-xs ttw:font-medium ttw:tabular-nums", $x = {
10502
- default: ["ttw:bg-muted ttw:text-muted-foreground", "ttw:group-data-[state=active]/tabs-trigger:bg-primary ttw:group-data-[state=active]/tabs-trigger:text-primary-foreground"],
10498
+ default: {
10499
+ underline: ["ttw:bg-muted ttw:text-muted-foreground", "ttw:group-data-[state=active]/tabs-trigger:bg-primary ttw:group-data-[state=active]/tabs-trigger:text-primary-foreground"],
10500
+ pills: ["ttw:bg-background ttw:text-muted-foreground", "ttw:group-data-[state=active]/tabs-trigger:bg-muted"]
10501
+ },
10503
10502
  warning: ["ttw:bg-warning-subtle ttw:text-warning-foreground"]
10504
10503
  };
10505
10504
  function eS({ className: t, count: n, countTone: r, children: i, ...a }) {
@@ -10510,7 +10509,7 @@ function eS({ className: t, count: n, countTone: r, children: i, ...a }) {
10510
10509
  ...a,
10511
10510
  children: [i, n ? /* @__PURE__ */ v(g, { children: [" ", /* @__PURE__ */ _("span", {
10512
10511
  "data-slot": "tabs-count",
10513
- className: Y(Qx, $x[r ?? "default"]),
10512
+ className: Y(Qx, r ? $x[r] : $x.default[o]),
10514
10513
  children: n
10515
10514
  })] }) : null]
10516
10515
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tesouro/embedded-components-react",
3
- "version": "0.11.7",
3
+ "version": "0.11.9",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": [