@tesouro/embedded-components-react 0.11.8 → 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 +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/lib/WidgetProvider.d.ts +7 -0
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/RootWidgetProvider.js +48 -45
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/WidgetProvider.js +119 -116
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/useTokenRefreshRef.js +8 -0
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/client.js +11 -8
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/expectedApiNotFound.js +2 -1
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/interceptor.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/util/dist/lib/widgetTokenManager.js +65 -53
- package/package.json +1 -1
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.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
|
|
7
|
-
import { createEmbeddedClient as
|
|
8
|
-
import { EmbedApiProvider as
|
|
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
|
|
11
|
-
import { UIProvider as
|
|
12
|
-
import { useDesignSystemEnsurer as
|
|
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
|
|
15
|
-
import { configureEmbeddedClient as
|
|
16
|
-
import { generateCorrelationId as
|
|
17
|
-
import { WidgetContext as
|
|
18
|
-
import { resolveOrgId as
|
|
19
|
-
import { useWidgetFetch as
|
|
20
|
-
import { deriveOrganizationStatus as
|
|
21
|
-
import { deriveWidgetInitState as
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
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 =
|
|
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] =
|
|
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
|
-
|
|
39
|
-
let z =
|
|
39
|
+
u(() => (t(R), () => n(R)), [R]);
|
|
40
|
+
let z = f(k);
|
|
40
41
|
z.current = k;
|
|
41
|
-
let B =
|
|
42
|
-
let e =
|
|
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:
|
|
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
|
-
|
|
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 =
|
|
64
|
-
|
|
66
|
+
let U = te(a(P));
|
|
67
|
+
u(() => {
|
|
65
68
|
U && U().catch(() => {});
|
|
66
69
|
}, [U]);
|
|
67
|
-
let { result:
|
|
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:
|
|
77
|
-
}),
|
|
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
|
-
|
|
91
|
-
let Z =
|
|
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 =
|
|
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
|
-
]), $ =
|
|
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
|
-
]),
|
|
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__ */
|
|
161
|
+
return /* @__PURE__ */ m(fe, {
|
|
159
162
|
client: R,
|
|
160
|
-
children: /* @__PURE__ */
|
|
163
|
+
children: /* @__PURE__ */ m(i, {
|
|
161
164
|
client: H,
|
|
162
165
|
organizationId: X,
|
|
163
166
|
widgetToken: k,
|
|
164
|
-
installClientSecret:
|
|
165
|
-
authEpoch:
|
|
166
|
-
organizationStatus:
|
|
167
|
-
children: /* @__PURE__ */
|
|
168
|
-
value:
|
|
169
|
-
children: /* @__PURE__ */
|
|
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
|
|
29
|
-
import { WidgetErrorBoundary as
|
|
30
|
-
import { DISCLOSURES_REQUIRED_TEST_ID as d, hasRenderableAcceptanceSurface as f, resolveDisclosuresBlockedReason as p, shouldGateOnDisclosuresAcceptance as
|
|
31
|
-
import { useContext as
|
|
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
|
|
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:
|
|
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 =
|
|
38
|
-
enabled:
|
|
39
|
-
organizationId:
|
|
40
|
-
rootCorrelationId:
|
|
41
|
-
widgetName:
|
|
42
|
-
widgetInstanceId:
|
|
43
|
-
}),
|
|
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
|
-
|
|
46
|
-
}, [b,
|
|
47
|
-
if (!
|
|
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
|
-
}, [
|
|
55
|
-
let
|
|
55
|
+
}, [F, I]);
|
|
56
|
+
let V = ne(ee(j));
|
|
56
57
|
m(() => {
|
|
57
|
-
|
|
58
|
-
}, [
|
|
59
|
-
let
|
|
60
|
-
|
|
61
|
-
let
|
|
62
|
-
if (!
|
|
63
|
-
let e = se(i(
|
|
64
|
-
tokenRef:
|
|
65
|
-
analyticsContextRef:
|
|
66
|
-
clientSecretRef:
|
|
67
|
-
gatewayRouting:
|
|
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
|
|
71
|
+
return O ? O(e) : e;
|
|
70
72
|
}, [
|
|
71
|
-
|
|
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
|
-
|
|
85
|
-
|
|
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
|
-
|
|
88
|
+
K,
|
|
89
|
+
W,
|
|
90
|
+
q
|
|
88
91
|
]);
|
|
89
|
-
he(
|
|
90
|
-
let Z = ue(
|
|
92
|
+
he(Qe, E);
|
|
93
|
+
let Z = ue(D, X ? void 0 : Y?.organizationId), $e = pe({
|
|
91
94
|
organizationId: Z,
|
|
92
|
-
cascadeOrgId:
|
|
93
|
-
ownsFetch:
|
|
94
|
-
parentStatus:
|
|
95
|
-
hasToken: !!
|
|
96
|
-
loading:
|
|
97
|
-
error:
|
|
98
|
-
hasResult: !!
|
|
99
|
-
initReplacementPending:
|
|
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:
|
|
104
|
+
enabled: I,
|
|
102
105
|
organizationId: Z,
|
|
103
|
-
rootCorrelationId:
|
|
104
|
-
widgetName:
|
|
105
|
-
widgetInstanceId:
|
|
106
|
+
rootCorrelationId: L,
|
|
107
|
+
widgetName: R,
|
|
108
|
+
widgetInstanceId: z
|
|
106
109
|
}), [
|
|
107
|
-
P,
|
|
108
|
-
Z,
|
|
109
|
-
F,
|
|
110
110
|
I,
|
|
111
|
-
|
|
111
|
+
Z,
|
|
112
|
+
L,
|
|
113
|
+
R,
|
|
114
|
+
z
|
|
112
115
|
]);
|
|
113
|
-
|
|
114
|
-
let [$] = _(() => S === null ? new
|
|
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
|
|
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
|
-
]),
|
|
143
|
-
baseUrl:
|
|
144
|
-
widgetToken:
|
|
145
|
+
]), tt = h(() => ({
|
|
146
|
+
baseUrl: T,
|
|
147
|
+
widgetToken: E,
|
|
145
148
|
organizationId: Z,
|
|
146
|
-
configClient:
|
|
147
|
-
gatewayRouting:
|
|
148
|
-
linkComponent:
|
|
149
|
-
uiFramework:
|
|
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
|
-
]),
|
|
161
|
-
resolved:
|
|
162
|
-
own:
|
|
163
|
-
refetch:
|
|
164
|
-
loading:
|
|
165
|
-
error:
|
|
163
|
+
]), nt = h(() => ({
|
|
164
|
+
resolved: tt,
|
|
165
|
+
own: et,
|
|
166
|
+
refetch: qe,
|
|
167
|
+
loading: Je,
|
|
168
|
+
error: Ye,
|
|
166
169
|
analytics: Q,
|
|
167
|
-
cascadeOrgId:
|
|
170
|
+
cascadeOrgId: D,
|
|
168
171
|
initResponseStaleForToken: X,
|
|
169
|
-
disclosuresAcceptance:
|
|
170
|
-
providerLabels:
|
|
172
|
+
disclosuresAcceptance: M,
|
|
173
|
+
providerLabels: N
|
|
171
174
|
}), [
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
tt,
|
|
176
|
+
et,
|
|
177
|
+
qe,
|
|
178
|
+
Je,
|
|
179
|
+
Ye,
|
|
177
180
|
Q,
|
|
178
|
-
|
|
181
|
+
D,
|
|
179
182
|
X,
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
]),
|
|
183
|
-
value:
|
|
183
|
+
M,
|
|
184
|
+
N
|
|
185
|
+
]), rt = /* @__PURE__ */ v(l.Provider, {
|
|
186
|
+
value: nt,
|
|
184
187
|
children: /* @__PURE__ */ v(te, {
|
|
185
|
-
linkComponent:
|
|
186
|
-
uiFramework:
|
|
187
|
-
children: /* @__PURE__ */ v(ie, { children: /* @__PURE__ */ v(
|
|
188
|
-
resetKeys: [
|
|
189
|
-
errorFallback:
|
|
190
|
-
onError:
|
|
191
|
-
labels:
|
|
192
|
-
children:
|
|
193
|
-
disclosuresAcceptance:
|
|
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:
|
|
198
|
+
labels: P
|
|
196
199
|
}) : re
|
|
197
200
|
}) })
|
|
198
201
|
})
|
|
199
|
-
}),
|
|
200
|
-
client:
|
|
202
|
+
}), it = H ? /* @__PURE__ */ v(a, {
|
|
203
|
+
client: H,
|
|
201
204
|
organizationId: Z,
|
|
202
|
-
widgetToken:
|
|
203
|
-
installClientSecret:
|
|
204
|
-
authEpoch:
|
|
205
|
-
organizationStatus:
|
|
206
|
-
children:
|
|
207
|
-
}) :
|
|
208
|
-
return $ ? /* @__PURE__ */ v(
|
|
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:
|
|
211
|
-
}) :
|
|
213
|
+
children: it
|
|
214
|
+
}) : it;
|
|
212
215
|
}
|
|
213
|
-
function
|
|
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 };
|
package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
CHANGED
|
@@ -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.
|
|
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
|
package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/client.js
CHANGED
|
@@ -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
|
|
6
|
-
return e(
|
|
7
|
-
tokenRef:
|
|
8
|
-
clientSecretRef:
|
|
9
|
-
gatewayRouting:
|
|
10
|
-
}),
|
|
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 {
|
|
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}`);
|
package/dist/libs/tesouro-embedded-components-react/shared/util/dist/lib/widgetTokenManager.js
CHANGED
|
@@ -1,89 +1,101 @@
|
|
|
1
1
|
// ../../libs/tesouro-embedded-components-react/shared/util/dist/lib/widgetTokenManager.js
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
},
|
|
15
|
+
}, T = (e) => {
|
|
15
16
|
let t = Math.max(0, e * 1e3 - Date.now());
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
h = setTimeout(() => {
|
|
18
|
+
h = void 0, a.status === "ready" && a.lastError !== void 0 && S({
|
|
18
19
|
status: "error",
|
|
19
|
-
error:
|
|
20
|
+
error: a.lastError
|
|
20
21
|
});
|
|
21
22
|
}, t);
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
...
|
|
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
|
|
30
|
+
let o, u, d = !1;
|
|
30
31
|
try {
|
|
31
|
-
|
|
32
|
+
o = await r();
|
|
32
33
|
} catch (e) {
|
|
33
34
|
d = !0, u = e;
|
|
34
35
|
}
|
|
35
|
-
if (
|
|
36
|
-
if (!d &&
|
|
37
|
-
|
|
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:
|
|
40
|
-
exp:
|
|
40
|
+
widgetToken: o.widgetToken,
|
|
41
|
+
exp: o.exp,
|
|
41
42
|
isRefreshing: !1
|
|
42
|
-
}),
|
|
43
|
+
}), l = 0, o.exp !== void 0 && w(o.exp);
|
|
43
44
|
return;
|
|
44
45
|
}
|
|
45
|
-
|
|
46
|
+
i.status === "ready" && (i.exp === void 0 || i.exp * 1e3 > Date.now()) ? (S({
|
|
46
47
|
status: "ready",
|
|
47
|
-
widgetToken:
|
|
48
|
-
exp:
|
|
48
|
+
widgetToken: i.widgetToken,
|
|
49
|
+
exp: i.exp,
|
|
49
50
|
isRefreshing: !1,
|
|
50
51
|
lastError: u
|
|
51
|
-
}),
|
|
52
|
+
}), i.exp !== void 0 && T(i.exp)) : S({
|
|
52
53
|
status: "error",
|
|
53
54
|
error: u
|
|
54
55
|
});
|
|
55
|
-
let
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
let t =
|
|
61
|
-
return
|
|
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 ===
|
|
67
|
+
n === c && (f = !1);
|
|
67
68
|
});
|
|
68
|
-
},
|
|
69
|
-
(e.type !== "visibilitychange" || document.visibilityState === "visible") &&
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
},
|
|
73
|
-
|
|
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
|
-
|
|
88
|
+
u || (u = !0, k(), D({ manual: !1 }));
|
|
78
89
|
},
|
|
79
90
|
stop: () => {
|
|
80
|
-
|
|
91
|
+
u = !1, s++, C(), j(), A();
|
|
81
92
|
},
|
|
82
|
-
refresh: () => (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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 };
|