@tesouro/embedded-components-loader 0.0.0 → 0.11.201
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/LICENSE +201 -0
- package/NOTICE +7 -0
- package/README.md +314 -5
- package/dist/caretRange.d.ts +13 -0
- package/dist/caretRange.d.ts.map +1 -0
- package/dist/entries.generated.d.ts +34 -0
- package/dist/entries.generated.d.ts.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +208 -0
- package/dist/loader.d.ts +66 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/react/experimental/BalanceHistoryWidget.d.ts +1382 -0
- package/dist/react/experimental/QuickViewWidget.d.ts +888 -0
- package/dist/react/experimental/RemoteCheckCapture.d.ts +714 -0
- package/dist/react/experimental/index.d.ts +1776 -0
- package/dist/react/index.d.ts +7444 -0
- package/dist/react/lib/AcceptDisclosuresWidget.d.ts +1457 -0
- package/dist/react/lib/BalancesWidget.d.ts +647 -0
- package/dist/react/lib/BankAccountOnboardingWidget.d.ts +2053 -0
- package/dist/react/lib/BankAccountsWidget.d.ts +773 -0
- package/dist/react/lib/BankingComplianceBannerWidget.d.ts +647 -0
- package/dist/react/lib/BillPayWidget.d.ts +666 -0
- package/dist/react/lib/CardDetailsWidget.d.ts +1647 -0
- package/dist/react/lib/CounterpartsWidget.d.ts +1698 -0
- package/dist/react/lib/CounterpartsWidgetPublic.d.ts +1697 -0
- package/dist/react/lib/CreditCardsWidget.d.ts +2153 -0
- package/dist/react/lib/DebitCardsWidget.d.ts +2149 -0
- package/dist/react/lib/ExpenseManagementWidget.d.ts +835 -0
- package/dist/react/lib/InsightsWidget.d.ts +696 -0
- package/dist/react/lib/LinkedAccountsWidget.d.ts +726 -0
- package/dist/react/lib/OfferWidget.d.ts +1421 -0
- package/dist/react/lib/ReceivablesWidget.d.ts +2556 -0
- package/dist/react/lib/RecentActivityWidget.d.ts +655 -0
- package/dist/react/lib/SettingsWidget.d.ts +775 -0
- package/dist/react/lib/TransfersWidget.d.ts +794 -0
- package/dist/react/lib/WidgetProvider.d.ts +1305 -0
- package/dist/react/lib/WidgetProviderPublic.d.ts +619 -0
- package/dist/react/lib/WidgetSuite.d.ts +5664 -0
- package/dist/stylesheet.d.ts +3 -0
- package/dist/stylesheet.d.ts.map +1 -0
- package/package.json +93 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Tesouro
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
CHANGED
|
@@ -1,8 +1,317 @@
|
|
|
1
1
|
# @tesouro/embedded-components-loader
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The loader for the hosted build of `@tesouro/embedded-components-react`: the
|
|
4
|
+
same widgets, served by Tesouro from `https://widgets.tesouro.com` instead of
|
|
5
|
+
bundled into your app. The hosted build renders with your page's own React,
|
|
6
|
+
which you hand to the loader (the injected React). The loader carries no widget
|
|
7
|
+
code of its own.
|
|
4
8
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
## Load from the Tesouro CDN
|
|
10
|
+
|
|
11
|
+
The hosted build is the npm package's code at one exact, unchanging version.
|
|
12
|
+
Everything else in [Getting started](https://components.tesouro.com/components/getting-started)
|
|
13
|
+
still applies: you need the same credentials and the same token route. Only how
|
|
14
|
+
the widgets reach the page changes.
|
|
15
|
+
|
|
16
|
+
There are two ways to load it, depending on whether your page has a build step.
|
|
17
|
+
Both end in the same call, `loadTesouro({ modules })`, which resolves once the
|
|
18
|
+
widget code and its stylesheet have loaded.
|
|
19
|
+
|
|
20
|
+
### With a bundler
|
|
21
|
+
|
|
22
|
+
Install the loader at an exact version. Loader `1.2.3` loads hosted `1.2.3`.
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install --save-exact @tesouro/embedded-components-loader
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Then make one awaited call with your `react`, `react-dom` and
|
|
29
|
+
`react/jsx-runtime` modules, before you render anything it returns:
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import * as React from 'react';
|
|
33
|
+
import * as ReactDOM from 'react-dom';
|
|
34
|
+
import * as jsxRuntime from 'react/jsx-runtime';
|
|
35
|
+
import { createRoot } from 'react-dom/client';
|
|
36
|
+
import { loadTesouro } from '@tesouro/embedded-components-loader';
|
|
37
|
+
|
|
38
|
+
const { RefreshingRootWidgetProvider, BankAccountsWidget } = await loadTesouro({
|
|
39
|
+
modules: { React, ReactDOM, jsxRuntime },
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
createRoot(document.getElementById('root')!).render(
|
|
43
|
+
<RefreshingRootWidgetProvider
|
|
44
|
+
baseUrl="https://api.sandbox.tesouro.com"
|
|
45
|
+
fetcher={fetcher}
|
|
46
|
+
>
|
|
47
|
+
<BankAccountsWidget />
|
|
48
|
+
</RefreshingRootWidgetProvider>,
|
|
49
|
+
);
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`fetcher` is the same function that calls your token route in Getting started.
|
|
53
|
+
The loader adds the widget stylesheet to the page itself, so do not import
|
|
54
|
+
`styles.css` from the npm package. The result is fully typed: every provider,
|
|
55
|
+
hook and widget has the npm package's types, with no other package to install.
|
|
56
|
+
|
|
57
|
+
### Without a build step
|
|
58
|
+
|
|
59
|
+
A page with no bundler imports `loader.js` from the version folder in a module
|
|
60
|
+
script and takes React as ES modules from a URL. esm.sh works:
|
|
61
|
+
|
|
62
|
+
```html
|
|
63
|
+
<div id="root"></div>
|
|
64
|
+
<script type="module">
|
|
65
|
+
import * as React from 'https://esm.sh/react@19.3.0';
|
|
66
|
+
import * as ReactDOM from 'https://esm.sh/react-dom@19.3.0?deps=react@19.3.0';
|
|
67
|
+
import * as jsxRuntime from 'https://esm.sh/react@19.3.0/jsx-runtime';
|
|
68
|
+
import { createRoot } from 'https://esm.sh/react-dom@19.3.0/client?deps=react@19.3.0';
|
|
69
|
+
import { loadTesouro } from 'https://widgets.tesouro.com/embedded-components-react/1.2.3/loader.js';
|
|
70
|
+
|
|
71
|
+
const fetcher = async () => {
|
|
72
|
+
const res = await fetch('/api/widget-token', { method: 'POST' });
|
|
73
|
+
if (!res.ok) throw new Error('Widget token request failed');
|
|
74
|
+
return res.json();
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const { RefreshingRootWidgetProvider, BankAccountsWidget } =
|
|
78
|
+
await loadTesouro({
|
|
79
|
+
modules: { React, ReactDOM, jsxRuntime },
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
createRoot(document.getElementById('root')).render(
|
|
83
|
+
React.createElement(
|
|
84
|
+
RefreshingRootWidgetProvider,
|
|
85
|
+
{ baseUrl: 'https://api.sandbox.tesouro.com', fetcher },
|
|
86
|
+
React.createElement(BankAccountsWidget),
|
|
87
|
+
),
|
|
88
|
+
);
|
|
89
|
+
</script>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Keep `?deps=react@19.3.0` on every `react-dom` URL. It makes esm.sh build
|
|
93
|
+
`react-dom` against that same React; without it, `react-dom` can bring its own
|
|
94
|
+
copy, and the page ends up with two.
|
|
95
|
+
|
|
96
|
+
### Pass the same React your app renders with
|
|
97
|
+
|
|
98
|
+
Pass the `react`, `react-dom` and `react/jsx-runtime` imports your app renders
|
|
99
|
+
with, not another copy. The loader checks that the versions are supported and
|
|
100
|
+
that `ReactDOM.version` matches `React.version`, but it checks version strings
|
|
101
|
+
only: it cannot prove which React your app renders with. A different copy fails
|
|
102
|
+
at first render with React's own "Invalid hook call" error.
|
|
103
|
+
|
|
104
|
+
### Take everything from the hosted build
|
|
105
|
+
|
|
106
|
+
Providers, hooks and widgets all come from the hosted build. Do not import a
|
|
107
|
+
provider from the npm package and render hosted widgets under it: that gives
|
|
108
|
+
two separate contexts, the widgets never see the provider, and nothing reports
|
|
109
|
+
an error.
|
|
110
|
+
|
|
111
|
+
### One hosted version per page
|
|
112
|
+
|
|
113
|
+
A page runs one hosted version. A call for a different version on the same page
|
|
114
|
+
rejects with `version-conflict`, whichever loader makes it.
|
|
115
|
+
|
|
116
|
+
### Pin the version
|
|
117
|
+
|
|
118
|
+
Nothing loads a "latest" version, and nothing tells a page that a newer version
|
|
119
|
+
exists. You choose when to move:
|
|
120
|
+
|
|
121
|
+
- **With a bundler,** the installed loader's version is the hosted version.
|
|
122
|
+
`--save-exact` keeps a lockfile refresh from moving it.
|
|
123
|
+
- **Without a build step,** the version is the folder in the `loader.js` URL.
|
|
124
|
+
Change the URL to change the version.
|
|
125
|
+
|
|
126
|
+
Each version folder is written once and kept, so a pinned page keeps working.
|
|
127
|
+
|
|
128
|
+
### Entries
|
|
129
|
+
|
|
130
|
+
Most pages need only the call above. `entry` narrows what loads, mirroring the
|
|
131
|
+
npm subpaths:
|
|
132
|
+
|
|
133
|
+
| `entry` | Loads | npm equivalent |
|
|
134
|
+
| -------------------------------- | ------------------------------------- | -------------------------------- |
|
|
135
|
+
| omitted | every stable widget | `…/embedded-components-react` |
|
|
136
|
+
| `'BillPayWidget'` | one stable widget, for a smaller load | `…/lib/BillPayWidget` |
|
|
137
|
+
| `'experimental'` | every experimental widget | `…/experimental` |
|
|
138
|
+
| `'experimental/QuickViewWidget'` | one experimental widget | `…/experimental/QuickViewWidget` |
|
|
139
|
+
|
|
140
|
+
Entries loaded on one page share their code and the stylesheet, so a second
|
|
141
|
+
entry fetches only what is new. Experimental entries carry no stability
|
|
142
|
+
promise: they can change or disappear in any version, including a patch, and a
|
|
143
|
+
widget that graduates moves to its stable name (`'QuickViewWidget'`).
|
|
144
|
+
|
|
145
|
+
`entry` is typed as the entry names this version publishes, and the promise
|
|
146
|
+
resolves to that entry's module type. A name only known at runtime needs a
|
|
147
|
+
cast to one of them; the loader still rejects it with `unknown-entry` if this
|
|
148
|
+
version does not have it.
|
|
149
|
+
|
|
150
|
+
Importing the loader does nothing; loading starts on the call. A second call
|
|
151
|
+
for the same entry while one is pending returns the same promise, and a failed
|
|
152
|
+
call is retried in full by the next one.
|
|
153
|
+
|
|
154
|
+
### Errors and retries
|
|
155
|
+
|
|
156
|
+
Every failure rejects with `TesouroLoaderError`. Branch on its `code`; the
|
|
157
|
+
message is not part of the contract.
|
|
158
|
+
|
|
159
|
+
| `code` | Meaning | Retry helps |
|
|
160
|
+
| ---------------------- | ------------------------------------------------------------ | ------------------- |
|
|
161
|
+
| `react-out-of-range` | Your React version is outside the supported range | No |
|
|
162
|
+
| `react-dom-mismatch` | `ReactDOM.version` differs from `React.version` | No |
|
|
163
|
+
| `react-export-missing` | Your React lacks an export the build imports | No |
|
|
164
|
+
| `version-conflict` | A different hosted version is already loaded on the page | No |
|
|
165
|
+
| `instance-conflict` | This version was already loaded with different React modules | No |
|
|
166
|
+
| `base-url-conflict` | This version was already loaded from a different `baseUrl` | No |
|
|
167
|
+
| `unknown-entry` | The entry is not in this version; the message lists them | No |
|
|
168
|
+
| `network` | The manifest, the entry script or the stylesheet failed | Yes, after a reload |
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
import { TesouroLoaderError } from '@tesouro/embedded-components-loader';
|
|
172
|
+
|
|
173
|
+
try {
|
|
174
|
+
await loadTesouro({ modules });
|
|
175
|
+
} catch (error) {
|
|
176
|
+
if (error instanceof TesouroLoaderError && error.code === 'network') {
|
|
177
|
+
// Offer a reload. Every other code needs an integration fix.
|
|
178
|
+
}
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Only `network` can succeed on a retry, and reloading the page is the reliable
|
|
184
|
+
retry. After the entry script fails, Chromium answers a second import of it
|
|
185
|
+
from its module map without making a request, so a retry on the same page fails
|
|
186
|
+
again; Firefox and WebKit fetch it again. The error does not say which file
|
|
187
|
+
failed, so a page cannot tell when a same-page retry would help. A retry on the
|
|
188
|
+
same page must use the same `baseUrl`; switching to a mirror is
|
|
189
|
+
`base-url-conflict`.
|
|
190
|
+
|
|
191
|
+
### Content Security Policy
|
|
192
|
+
|
|
193
|
+
Two policy forms work in Chromium, Firefox and WebKit. The examples show what
|
|
194
|
+
the widgets need, with `'self'` for your own token route and stylesheets; merge
|
|
195
|
+
them into your existing policy. Wherever they name
|
|
196
|
+
`https://widgets.tesouro.com`, a page that loads from a mirror names the mirror
|
|
197
|
+
instead.
|
|
198
|
+
|
|
199
|
+
**A nonce with `'strict-dynamic'`.** Put the page's nonce on the import map, if
|
|
200
|
+
you use one (see Integrity), and on the page's module script.
|
|
201
|
+
`'strict-dynamic'` then trusts every script those load: the loader,
|
|
202
|
+
the entry, its chunks and React from a URL.
|
|
203
|
+
|
|
204
|
+
```text
|
|
205
|
+
script-src 'nonce-<random>' 'strict-dynamic';
|
|
206
|
+
style-src 'self' https://widgets.tesouro.com;
|
|
207
|
+
connect-src 'self' https://widgets.tesouro.com https://api.tesouro.com https://z.tesouro.com <file URL origins>;
|
|
208
|
+
worker-src https://widgets.tesouro.com blob:;
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
**A host allowlist.** Name `https://widgets.tesouro.com` and wherever React
|
|
212
|
+
comes from, such as `https://esm.sh`. An inline import map or module script
|
|
213
|
+
still needs its nonce, as any inline script does.
|
|
214
|
+
|
|
215
|
+
```text
|
|
216
|
+
script-src 'self' https://widgets.tesouro.com https://esm.sh;
|
|
217
|
+
style-src 'self' https://widgets.tesouro.com;
|
|
218
|
+
connect-src 'self' https://widgets.tesouro.com https://api.tesouro.com https://z.tesouro.com <file URL origins>;
|
|
219
|
+
worker-src https://widgets.tesouro.com blob:;
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Never rely on hashes alone. With only `'sha256-…'` sources in `script-src`,
|
|
223
|
+
WebKit refuses a chunk reached by a static import, and the pdf.js worker behind
|
|
224
|
+
PDF previews cannot load.
|
|
225
|
+
|
|
226
|
+
What each directive is for:
|
|
227
|
+
|
|
228
|
+
| Directive | Allow |
|
|
229
|
+
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
230
|
+
| `script-src` | One of the two forms above. |
|
|
231
|
+
| `style-src` | The CDN origin, for `index.css`. |
|
|
232
|
+
| `connect-src` | The CDN origin, for `manifest.json`; your API origin (`https://api.sandbox.tesouro.com` in sandbox); `https://z.tesouro.com` for analytics, unless the provider has `analytics={false}`; the origins of the file URLs the API returns. |
|
|
233
|
+
| `worker-src` | Optional. If you set it, the CDN origin plus `blob:`. |
|
|
234
|
+
|
|
235
|
+
Under a strict `style-src`, three inline styles that dependencies add are still
|
|
236
|
+
refused. The npm package has the same three, so the hosted build adds none.
|
|
237
|
+
|
|
238
|
+
### Integrity
|
|
239
|
+
|
|
240
|
+
To check every script against the hash Tesouro published, give the page an
|
|
241
|
+
import map with an `integrity` section, filled from the `files` list in the
|
|
242
|
+
version's `manifest.json`. It covers the loader, the entry and every chunk it
|
|
243
|
+
imports, in all three engines. It must come before any module script on the
|
|
244
|
+
page.
|
|
245
|
+
|
|
246
|
+
```html
|
|
247
|
+
<script type="importmap" nonce="<random>">
|
|
248
|
+
{
|
|
249
|
+
"integrity": {
|
|
250
|
+
"https://widgets.tesouro.com/embedded-components-react/1.2.3/loader.js": "sha384-...",
|
|
251
|
+
"https://widgets.tesouro.com/embedded-components-react/1.2.3/index.js": "sha384-...",
|
|
252
|
+
"https://widgets.tesouro.com/embedded-components-react/1.2.3/chunks/...": "sha384-..."
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
</script>
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Build the section when you deploy, from the manifest of the version you pin,
|
|
259
|
+
not in the page:
|
|
260
|
+
|
|
261
|
+
```js
|
|
262
|
+
const folder = 'https://widgets.tesouro.com/embedded-components-react/1.2.3';
|
|
263
|
+
const manifest = await (await fetch(`${folder}/manifest.json`)).json();
|
|
264
|
+
const integrity = Object.fromEntries(
|
|
265
|
+
manifest.files
|
|
266
|
+
.filter((file) => file.path.endsWith('.js'))
|
|
267
|
+
.map((file) => [`${folder}/${file.path}`, file.integrity]),
|
|
268
|
+
);
|
|
269
|
+
console.log(JSON.stringify({ integrity }, null, 2));
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
Never use a script tag's `integrity` attribute instead. It covers only the file
|
|
273
|
+
the tag names, not the entry or the chunks, and in Firefox and WebKit a tampered
|
|
274
|
+
loader that the tag refused still ran when the page imported the same URL.
|
|
275
|
+
|
|
276
|
+
The stylesheet, the manifest and the pdf.js worker are outside both: nothing
|
|
277
|
+
checks their integrity.
|
|
278
|
+
|
|
279
|
+
### Mirrors
|
|
280
|
+
|
|
281
|
+
A mirror is a copy of the Tesouro CDN root that you serve from your own origin.
|
|
282
|
+
To make one:
|
|
283
|
+
|
|
284
|
+
1. Copy the version folder, `embedded-components-react/<version>/`.
|
|
285
|
+
2. Copy every file the manifest's `externals` list names, such as the pdf.js
|
|
286
|
+
worker under `deps/`. These paths are relative to the root, not to the
|
|
287
|
+
version folder.
|
|
288
|
+
3. Keep every path as it is under the root.
|
|
289
|
+
4. Point the loader at the mirror root:
|
|
290
|
+
|
|
291
|
+
```ts
|
|
292
|
+
await loadTesouro({ modules, baseUrl: 'https://assets.example.com/tesouro' });
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
Without a build step, import `loader.js` from the mirror too. The pdf.js worker
|
|
296
|
+
follows: the hosted build finds `deps/` from its own URL. Serve `.js` files with
|
|
297
|
+
a JavaScript content type, such as `text/javascript`, because browsers refuse a
|
|
298
|
+
module script served as anything else. If the mirror is on a different origin
|
|
299
|
+
from the page, serve it with CORS headers, because module scripts are fetched
|
|
300
|
+
with CORS.
|
|
301
|
+
|
|
302
|
+
### Credentials
|
|
303
|
+
|
|
304
|
+
Do not put `crossorigin="use-credentials"` on a script tag that loads from the
|
|
305
|
+
CDN. The CDN answers CORS with a wildcard origin and no credentials, so a
|
|
306
|
+
credentialed request is refused. The default (no `crossorigin` attribute on a
|
|
307
|
+
module script) is right.
|
|
308
|
+
|
|
309
|
+
### What this package loads
|
|
310
|
+
|
|
311
|
+
Today the loader loads the React build. The elements build, for pages without
|
|
312
|
+
React, will load through a second export of this package later, at the same
|
|
313
|
+
version.
|
|
314
|
+
|
|
315
|
+
## License
|
|
316
|
+
|
|
317
|
+
Apache-2.0. See `LICENSE` and `NOTICE`.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type Triple = readonly [number, number, number];
|
|
2
|
+
/** `[lowest, firstExcluded]` per alternative; throws on any other range form. */
|
|
3
|
+
export declare function parseCaretRange(range: string): Array<[Triple, Triple]>;
|
|
4
|
+
/**
|
|
5
|
+
* semver `satisfies` with `includePrerelease`: a Next.js App Router host
|
|
6
|
+
* injects a canary such as `19.3.0-canary-…`, which must pass `^19.0.0`
|
|
7
|
+
* (ADR 0019). A prerelease of the lower bound itself (`19.0.0-rc`) sorts below
|
|
8
|
+
* it and fails; a prerelease of the upper bound (`20.0.0-canary`) is not below
|
|
9
|
+
* it and fails too, matching semver's `<20.0.0-0`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function satisfiesRange(version: string, range: string): boolean;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=caretRange.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"caretRange.d.ts","sourceRoot":"","sources":["../src/caretRange.ts"],"names":[],"mappings":"AAQA,KAAK,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAShD,iFAAiF;AACjF,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAatE;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAYtE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type * as Barrel from './react/index.js';
|
|
2
|
+
/** The module `loadTesouro()` resolves to when no entry is named. */
|
|
3
|
+
export type TesouroBarrelModule = typeof Barrel;
|
|
4
|
+
/** Entry name → the module `loadTesouro({ entry })` resolves to. */
|
|
5
|
+
export interface TesouroEntryModules {
|
|
6
|
+
AcceptDisclosuresWidget: typeof import('./react/lib/AcceptDisclosuresWidget.js');
|
|
7
|
+
BalancesWidget: typeof import('./react/lib/BalancesWidget.js');
|
|
8
|
+
BankAccountOnboardingWidget: typeof import('./react/lib/BankAccountOnboardingWidget.js');
|
|
9
|
+
BankAccountsWidget: typeof import('./react/lib/BankAccountsWidget.js');
|
|
10
|
+
BankingComplianceBannerWidget: typeof import('./react/lib/BankingComplianceBannerWidget.js');
|
|
11
|
+
BillPayWidget: typeof import('./react/lib/BillPayWidget.js');
|
|
12
|
+
CardDetailsWidget: typeof import('./react/lib/CardDetailsWidget.js');
|
|
13
|
+
CounterpartsWidget: typeof import('./react/lib/CounterpartsWidget.js');
|
|
14
|
+
CounterpartsWidgetPublic: typeof import('./react/lib/CounterpartsWidgetPublic.js');
|
|
15
|
+
CreditCardsWidget: typeof import('./react/lib/CreditCardsWidget.js');
|
|
16
|
+
DebitCardsWidget: typeof import('./react/lib/DebitCardsWidget.js');
|
|
17
|
+
ExpenseManagementWidget: typeof import('./react/lib/ExpenseManagementWidget.js');
|
|
18
|
+
InsightsWidget: typeof import('./react/lib/InsightsWidget.js');
|
|
19
|
+
LinkedAccountsWidget: typeof import('./react/lib/LinkedAccountsWidget.js');
|
|
20
|
+
OfferWidget: typeof import('./react/lib/OfferWidget.js');
|
|
21
|
+
ReceivablesWidget: typeof import('./react/lib/ReceivablesWidget.js');
|
|
22
|
+
RecentActivityWidget: typeof import('./react/lib/RecentActivityWidget.js');
|
|
23
|
+
SettingsWidget: typeof import('./react/lib/SettingsWidget.js');
|
|
24
|
+
TransfersWidget: typeof import('./react/lib/TransfersWidget.js');
|
|
25
|
+
WidgetProvider: typeof import('./react/lib/WidgetProvider.js');
|
|
26
|
+
WidgetProviderPublic: typeof import('./react/lib/WidgetProviderPublic.js');
|
|
27
|
+
WidgetSuite: typeof import('./react/lib/WidgetSuite.js');
|
|
28
|
+
/** Every experimental widget. No promise: see ADR 0008. */
|
|
29
|
+
experimental: typeof import('./react/experimental/index.js');
|
|
30
|
+
'experimental/BalanceHistoryWidget': typeof import('./react/experimental/BalanceHistoryWidget.js');
|
|
31
|
+
'experimental/QuickViewWidget': typeof import('./react/experimental/QuickViewWidget.js');
|
|
32
|
+
'experimental/RemoteCheckCapture': typeof import('./react/experimental/RemoteCheckCapture.js');
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=entries.generated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entries.generated.d.ts","sourceRoot":"","sources":["../src/entries.generated.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,MAAM,oCAAoC,CAAC;AAElE,qEAAqE;AACrE,MAAM,MAAM,mBAAmB,GAAG,OAAO,MAAM,CAAC;AAEhD,oEAAoE;AACpE,MAAM,WAAW,mBAAmB;IAClC,uBAAuB,EAAE,cAAc,gEAAgE,CAAC,CAAC;IACzG,cAAc,EAAE,cAAc,uDAAuD,CAAC,CAAC;IACvF,2BAA2B,EAAE,cAAc,oEAAoE,CAAC,CAAC;IACjH,kBAAkB,EAAE,cAAc,2DAA2D,CAAC,CAAC;IAC/F,6BAA6B,EAAE,cAAc,sEAAsE,CAAC,CAAC;IACrH,aAAa,EAAE,cAAc,sDAAsD,CAAC,CAAC;IACrF,iBAAiB,EAAE,cAAc,0DAA0D,CAAC,CAAC;IAC7F,kBAAkB,EAAE,cAAc,2DAA2D,CAAC,CAAC;IAC/F,wBAAwB,EAAE,cAAc,iEAAiE,CAAC,CAAC;IAC3G,iBAAiB,EAAE,cAAc,0DAA0D,CAAC,CAAC;IAC7F,gBAAgB,EAAE,cAAc,yDAAyD,CAAC,CAAC;IAC3F,uBAAuB,EAAE,cAAc,gEAAgE,CAAC,CAAC;IACzG,cAAc,EAAE,cAAc,uDAAuD,CAAC,CAAC;IACvF,oBAAoB,EAAE,cAAc,6DAA6D,CAAC,CAAC;IACnG,WAAW,EAAE,cAAc,oDAAoD,CAAC,CAAC;IACjF,iBAAiB,EAAE,cAAc,0DAA0D,CAAC,CAAC;IAC7F,oBAAoB,EAAE,cAAc,6DAA6D,CAAC,CAAC;IACnG,cAAc,EAAE,cAAc,uDAAuD,CAAC,CAAC;IACvF,eAAe,EAAE,cAAc,wDAAwD,CAAC,CAAC;IACzF,cAAc,EAAE,cAAc,uDAAuD,CAAC,CAAC;IACvF,oBAAoB,EAAE,cAAc,6DAA6D,CAAC,CAAC;IACnG,WAAW,EAAE,cAAc,oDAAoD,CAAC,CAAC;IACjF,2DAA2D;IAC3D,YAAY,EAAE,cAAc,iDAAiD,CAAC,CAAC;IAC/E,mCAAmC,EAAE,cAAc,sEAAsE,CAAC,CAAC;IAC3H,8BAA8B,EAAE,cAAc,iEAAiE,CAAC,CAAC;IACjH,iCAAiC,EAAE,cAAc,oEAAoE,CAAC,CAAC;CACxH"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TesouroBarrelModule, TesouroEntryModules } from './entries.generated.js';
|
|
2
|
+
import { LoadTesouroOptions } from './loader.js';
|
|
3
|
+
export { TesouroLoaderError, type LoadTesouroOptions, type TesouroLoaderErrorCode, type TesouroReactModules, } from './loader.js';
|
|
4
|
+
export type { TesouroBarrelModule, TesouroEntryModules, } from './entries.generated.js';
|
|
5
|
+
export type TesouroEntry = keyof TesouroEntryModules;
|
|
6
|
+
export interface LoadTesouro {
|
|
7
|
+
(options: LoadTesouroOptions & {
|
|
8
|
+
entry?: undefined;
|
|
9
|
+
}): Promise<TesouroBarrelModule>;
|
|
10
|
+
<E extends TesouroEntry>(options: LoadTesouroOptions & {
|
|
11
|
+
entry: E;
|
|
12
|
+
}): Promise<TesouroEntryModules[E]>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Load the hosted React build of this loader's own version with the host's
|
|
16
|
+
* React. Nothing happens at import time: every default below is read on call.
|
|
17
|
+
*/
|
|
18
|
+
export declare const loadTesouro: LoadTesouro;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,kBAAkB,EAClB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,GACzB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,YAAY,GAAG,MAAM,mBAAmB,CAAC;AAErD,MAAM,WAAW,WAAW;IAC1B,CACE,OAAO,EAAE,kBAAkB,GAAG;QAAE,KAAK,CAAC,EAAE,SAAS,CAAA;KAAE,GAClD,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAChC,CAAC,CAAC,SAAS,YAAY,EACrB,OAAO,EAAE,kBAAkB,GAAG;QAAE,KAAK,EAAE,CAAC,CAAA;KAAE,GACzC,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;CACpC;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,EAelB,WAAW,CAAC"}
|