@tesouro/embedded-components-react 0.3.53 → 0.3.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +0 -20
  2. package/dist/index.d.ts +2 -22
  3. package/dist/index.js +44 -48
  4. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +1 -1
  5. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index16.js +65 -3
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index17.js +4 -5
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index18.js +5 -4
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index19.js +3 -32
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index20.js +30 -37
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index21.js +37 -158
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index22.js +165 -28
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index23.js +48 -1
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index24.js +1 -50
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index25.js +47 -4
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index26.js +4 -13
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js +13 -14
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js +7 -57
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js +54 -16
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js +24 -60
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js +1 -1
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js +1 -1
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.js +2 -2
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +6 -6
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js +98 -98
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +51 -53
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +1 -1
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +131 -140
  28. package/dist/libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index.js +4 -4
  29. package/dist/libs/tesouro-embedded-components-react/monite-sdk/dist/index22.js +1 -1
  30. package/dist/libs/tesouro-embedded-components-react/monite-sdk/dist/index98.js +47 -29
  31. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/data-access/dist/index5.js +6 -6
  32. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/index.js +6 -5
  33. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/helpers.js +2 -3
  34. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/usePayableAchInstructions.js +18 -0
  35. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  36. package/package.json +1 -1
  37. package/dist/lib/CreateCardWidget.d.ts +0 -823
  38. package/dist/lib/CreateCardWidget.js +0 -5
@@ -1,823 +0,0 @@
1
- import * as React from 'react';
2
- import { ComponentType, AnchorHTMLAttributes, ReactNode, ErrorInfo } from 'react';
3
- import { FallbackProps } from 'react-error-boundary';
4
-
5
- /**
6
- * Reset-period tab labels and notice copy are deliberately absent: the owner
7
- * supplies those through `spendLimitPeriodOptions` / `spendLimitPeriodNotices`,
8
- * so declaring them here would give consumers override keys that no component
9
- * ever reads.
10
- */
11
- interface CardControlsLabels {
12
- currencySymbol: string;
13
- spendLimit: {
14
- title: string;
15
- description: string;
16
- amountPlaceholder: string;
17
- amountAriaLabel: string;
18
- };
19
- merchantCategories: {
20
- title: string;
21
- description: string;
22
- };
23
- perTransactionMaximum: {
24
- title: string;
25
- description: string;
26
- amountPlaceholder: string;
27
- amountAriaLabel: string;
28
- };
29
- }
30
-
31
- type PartialDeep<T> = {
32
- [K in keyof T]?: T[K] extends object ? PartialDeep<T[K]> : T[K];
33
- };
34
- interface CreateCardWidgetLabels {
35
- header: {
36
- title: string;
37
- closeAriaLabel: string;
38
- };
39
- cardArtAlt: string;
40
- setup: {
41
- sectionTitle: string;
42
- cardholderLabel: string;
43
- cardholderPlaceholder: string;
44
- cardFormatLabel: string;
45
- cardFormatPlaceholder: string;
46
- cardFormatVirtual: string;
47
- cardFormatPhysical: string;
48
- fundingAccountLabel: string;
49
- fundingAccountPlaceholder: string;
50
- };
51
- mailing: {
52
- sectionTitle: string;
53
- sectionDescription: string;
54
- businessTitle: string;
55
- businessDescription: string;
56
- customTitle: string;
57
- customDescription: string;
58
- };
59
- manualAddress: {
60
- streetLabel: string;
61
- cityLabel: string;
62
- stateLabel: string;
63
- statePlaceholder: string;
64
- zipLabel: string;
65
- };
66
- cardControls: CardControlsLabels;
67
- preparing: {
68
- title: string;
69
- description: string;
70
- };
71
- success: {
72
- title: string;
73
- description: string;
74
- createAnother: string;
75
- viewCard: string;
76
- };
77
- footer: {
78
- cancel: string;
79
- createCard: string;
80
- };
81
- cardholderError: {
82
- title: string;
83
- description: string;
84
- retry: string;
85
- };
86
- fundingAccountError: {
87
- title: string;
88
- description: string;
89
- retry: string;
90
- };
91
- }
92
-
93
- type AuthToken = string | undefined;
94
- interface Auth {
95
- /**
96
- * Which part of the request do we use to send the auth?
97
- *
98
- * @default 'header'
99
- */
100
- in?: 'header' | 'query' | 'cookie';
101
- /**
102
- * A unique identifier for the security scheme.
103
- *
104
- * Defined only when there are multiple security schemes whose `Auth`
105
- * shape would otherwise be identical.
106
- */
107
- key?: string;
108
- /**
109
- * Header or query parameter name.
110
- *
111
- * @default 'Authorization'
112
- */
113
- name?: string;
114
- scheme?: 'basic' | 'bearer';
115
- type: 'apiKey' | 'http';
116
- }
117
-
118
- interface SerializerOptions<T> {
119
- /**
120
- * @default true
121
- */
122
- explode: boolean;
123
- style: T;
124
- }
125
- type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
126
- type ObjectStyle = 'form' | 'deepObject';
127
-
128
- type QuerySerializer = (query: Record<string, unknown>) => string;
129
- type BodySerializer = (body: unknown) => unknown;
130
- type QuerySerializerOptionsObject = {
131
- allowReserved?: boolean;
132
- array?: Partial<SerializerOptions<ArrayStyle>>;
133
- object?: Partial<SerializerOptions<ObjectStyle>>;
134
- };
135
- type QuerySerializerOptions = QuerySerializerOptionsObject & {
136
- /**
137
- * Per-parameter serialization overrides. When provided, these settings
138
- * override the global array/object settings for specific parameter names.
139
- */
140
- parameters?: Record<string, QuerySerializerOptionsObject>;
141
- };
142
-
143
- type HttpMethod = 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
144
- type Client$1<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never, SseFn = never> = {
145
- /**
146
- * Returns the final request URL.
147
- */
148
- buildUrl: BuildUrlFn;
149
- getConfig: () => Config;
150
- request: RequestFn;
151
- setConfig: (config: Config) => Config;
152
- } & {
153
- [K in HttpMethod]: MethodFn;
154
- } & ([SseFn] extends [never] ? {
155
- sse?: never;
156
- } : {
157
- sse: {
158
- [K in HttpMethod]: SseFn;
159
- };
160
- });
161
- interface Config$1 {
162
- /**
163
- * Auth token or a function returning auth token. The resolved value will be
164
- * added to the request payload as defined by its `security` array.
165
- */
166
- auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
167
- /**
168
- * A function for serializing request body parameter. By default,
169
- * {@link JSON.stringify()} will be used.
170
- */
171
- bodySerializer?: BodySerializer | null;
172
- /**
173
- * An object containing any HTTP headers that you want to pre-populate your
174
- * `Headers` object with.
175
- *
176
- * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
177
- */
178
- headers?: RequestInit['headers'] | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>;
179
- /**
180
- * The request method.
181
- *
182
- * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
183
- */
184
- method?: Uppercase<HttpMethod>;
185
- /**
186
- * A function for serializing request query parameters. By default, arrays
187
- * will be exploded in form style, objects will be exploded in deepObject
188
- * style, and reserved characters are percent-encoded.
189
- *
190
- * This method will have no effect if the native `paramsSerializer()` Axios
191
- * API function is used.
192
- *
193
- * {@link https://swagger.io/docs/specification/serialization/#query View examples}
194
- */
195
- querySerializer?: QuerySerializer | QuerySerializerOptions;
196
- /**
197
- * A function validating request data. This is useful if you want to ensure
198
- * the request conforms to the desired shape, so it can be safely sent to
199
- * the server.
200
- */
201
- requestValidator?: (data: unknown) => Promise<unknown>;
202
- /**
203
- * A function transforming response data before it's returned. This is useful
204
- * for post-processing data, e.g., converting ISO strings into Date objects.
205
- */
206
- responseTransformer?: (data: unknown) => Promise<unknown>;
207
- /**
208
- * A function validating response data. This is useful if you want to ensure
209
- * the response conforms to the desired shape, so it can be safely passed to
210
- * the transformers and returned to the user.
211
- */
212
- responseValidator?: (data: unknown) => Promise<unknown>;
213
- }
214
-
215
- type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & Pick<Config$1, 'method' | 'responseTransformer' | 'responseValidator'> & {
216
- /**
217
- * Fetch API implementation. You can use this option to provide a custom
218
- * fetch instance.
219
- *
220
- * @default globalThis.fetch
221
- */
222
- fetch?: typeof fetch;
223
- /**
224
- * Implementing clients can call request interceptors inside this hook.
225
- */
226
- onRequest?: (url: string, init: RequestInit) => Promise<Request>;
227
- /**
228
- * Callback invoked when a network or parsing error occurs during streaming.
229
- *
230
- * This option applies only if the endpoint returns a stream of events.
231
- *
232
- * @param error The error that occurred.
233
- */
234
- onSseError?: (error: unknown) => void;
235
- /**
236
- * Callback invoked when an event is streamed from the server.
237
- *
238
- * This option applies only if the endpoint returns a stream of events.
239
- *
240
- * @param event Event streamed from the server.
241
- * @returns Nothing (void).
242
- */
243
- onSseEvent?: (event: StreamEvent<TData>) => void;
244
- serializedBody?: RequestInit['body'];
245
- /**
246
- * Default retry delay in milliseconds.
247
- *
248
- * This option applies only if the endpoint returns a stream of events.
249
- *
250
- * @default 3000
251
- */
252
- sseDefaultRetryDelay?: number;
253
- /**
254
- * Maximum number of retry attempts before giving up.
255
- */
256
- sseMaxRetryAttempts?: number;
257
- /**
258
- * Maximum retry delay in milliseconds.
259
- *
260
- * Applies only when exponential backoff is used.
261
- *
262
- * This option applies only if the endpoint returns a stream of events.
263
- *
264
- * @default 30000
265
- */
266
- sseMaxRetryDelay?: number;
267
- /**
268
- * Optional sleep function for retry backoff.
269
- *
270
- * Defaults to using `setTimeout`.
271
- */
272
- sseSleepFn?: (ms: number) => Promise<void>;
273
- url: string;
274
- };
275
- interface StreamEvent<TData = unknown> {
276
- data: TData;
277
- event?: string;
278
- id?: string;
279
- retry?: number;
280
- }
281
- type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
282
- stream: AsyncGenerator<TData extends Record<string, unknown> ? TData[keyof TData] : TData, TReturn, TNext>;
283
- };
284
-
285
- type ErrInterceptor<Err, Res, Req, Options> = (error: Err,
286
- /** response may be undefined due to a network error where no response object is produced */
287
- response: Res | undefined,
288
- /** request may be undefined, because error may be from building the request object itself */
289
- request: Req | undefined, options: Options) => Err | Promise<Err>;
290
- type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
291
- type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
292
- declare class Interceptors<Interceptor> {
293
- fns: Array<Interceptor | null>;
294
- clear(): void;
295
- eject(id: number | Interceptor): void;
296
- exists(id: number | Interceptor): boolean;
297
- getInterceptorIndex(id: number | Interceptor): number;
298
- update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
299
- use(fn: Interceptor): number;
300
- }
301
- interface Middleware<Req, Res, Err, Options> {
302
- error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
303
- request: Interceptors<ReqInterceptor<Req, Options>>;
304
- response: Interceptors<ResInterceptor<Res, Req, Options>>;
305
- }
306
-
307
- type ResponseStyle = 'data' | 'fields';
308
- interface Config<T extends ClientOptions$1 = ClientOptions$1> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, Config$1 {
309
- /**
310
- * Base URL for all requests made by this client.
311
- */
312
- baseUrl?: T['baseUrl'];
313
- /**
314
- * Fetch API implementation. You can use this option to provide a custom
315
- * fetch instance.
316
- *
317
- * @default globalThis.fetch
318
- */
319
- fetch?: typeof fetch;
320
- /**
321
- * Please don't use the Fetch client for Next.js applications. The `next`
322
- * options won't have any effect.
323
- *
324
- * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
325
- */
326
- next?: never;
327
- /**
328
- * Return the response data parsed in a specified format. By default, `auto`
329
- * will infer the appropriate method from the `Content-Type` response header.
330
- * You can override this behavior with any of the {@link Body} methods.
331
- * Select `stream` if you don't want to parse response data at all.
332
- *
333
- * @default 'auto'
334
- */
335
- parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
336
- /**
337
- * Should we return only data or multiple fields (data, error, response, etc.)?
338
- *
339
- * @default 'fields'
340
- */
341
- responseStyle?: ResponseStyle;
342
- /**
343
- * Throw an error instead of returning it in the response?
344
- *
345
- * @default false
346
- */
347
- throwOnError?: T['throwOnError'];
348
- }
349
- interface RequestOptions<TData = unknown, TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
350
- responseStyle: TResponseStyle;
351
- throwOnError: ThrowOnError;
352
- }>, Pick<ServerSentEventsOptions<TData>, 'onRequest' | 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> {
353
- /**
354
- * Any body that you want to add to your request.
355
- *
356
- * {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
357
- */
358
- body?: unknown;
359
- path?: Record<string, unknown>;
360
- query?: Record<string, unknown>;
361
- /**
362
- * Security mechanism(s) to use for the request.
363
- */
364
- security?: ReadonlyArray<Auth>;
365
- url: Url;
366
- }
367
- interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
368
- headers: Headers;
369
- serializedBody?: string;
370
- }
371
- type RequestResult<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean, TResponseStyle extends ResponseStyle = 'fields'> = ThrowOnError extends true ? Promise<TResponseStyle extends 'data' ? TData extends Record<string, unknown> ? TData[keyof TData] : TData : {
372
- data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
373
- request: Request;
374
- response: Response;
375
- }> : Promise<TResponseStyle extends 'data' ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined : ({
376
- data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
377
- error: undefined;
378
- } | {
379
- data: undefined;
380
- error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
381
- }) & {
382
- /** request may be undefined, because error may be from building the request object itself */
383
- request?: Request;
384
- /** response may be undefined, because error may be from building the request object itself or from a network error */
385
- response?: Response;
386
- }>;
387
- interface ClientOptions$1 {
388
- baseUrl?: string;
389
- responseStyle?: ResponseStyle;
390
- throwOnError?: boolean;
391
- }
392
- type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
393
- type SseFn = <TData = unknown, _TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<never, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData>>;
394
- type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> & Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
395
- type BuildUrlFn = <TData extends {
396
- body?: unknown;
397
- path?: Record<string, unknown>;
398
- query?: Record<string, unknown>;
399
- url: string;
400
- }>(options: TData & Options<TData>) => string;
401
- type Client = Client$1<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
402
- interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
403
- };
404
- interface TDataShape {
405
- body?: unknown;
406
- headers?: unknown;
407
- path?: unknown;
408
- query?: unknown;
409
- url: string;
410
- }
411
- type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
412
- type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown, TResponseStyle extends ResponseStyle = 'fields'> = OmitKeys<RequestOptions<TResponse, TResponseStyle, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & ([TData] extends [never] ? unknown : Omit<TData, 'url'>);
413
-
414
- type ClientOptions = {
415
- baseUrl: 'https://api.stage.tesouro.com' | 'https://api.sandbox.stage.tesouro.com' | 'https://api.stage.business-banking.app' | 'https://api.tesouro.com' | 'https://api.sandbox.tesouro.com' | 'https://api.business-banking.app' | (string & {});
416
- };
417
-
418
- type EmbeddedClient = Client;
419
- type ExtractLiterals<T> = T extends string ? string extends T ? never : T : never;
420
- type BaseUrl = ExtractLiterals<ClientOptions['baseUrl']>;
421
-
422
- type LinkComponentProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
423
- children?: ReactNode;
424
- };
425
- type LinkComponent = ComponentType<LinkComponentProps>;
426
- /**
427
- * The UI frameworks a widget's UI layer can render with.
428
- *
429
- * - `shadcn` — the shadcn/Tailwind implementation. This is the default and the
430
- * implicit fallback, so existing consumers that select nothing keep rendering
431
- * shadcn.
432
- * - `tecton` — the Tecton implementation.
433
- *
434
- * Declared as an `as const` object (not a TypeScript `enum`) per repo
435
- * convention.
436
- */
437
- declare const UIFramework: {
438
- readonly Shadcn: "shadcn";
439
- readonly Tecton: "tecton";
440
- };
441
- type UIFramework = (typeof UIFramework)[keyof typeof UIFramework];
442
-
443
- /**
444
- * The implementation a widget renders with.
445
- *
446
- * - `native` — the Tesouro-native implementation. This is the default and the
447
- * implicit fallback, so consumers that select nothing keep rendering native.
448
- * - `monite` — the Monite SDK implementation.
449
- *
450
- * Declared as an `as const` object (not a TypeScript `enum`) per repo
451
- * convention.
452
- */
453
- declare const Implementation: {
454
- readonly Native: "native";
455
- readonly Monite: "monite";
456
- };
457
- type Implementation = (typeof Implementation)[keyof typeof Implementation];
458
- /**
459
- * The settable fields of the widget config cascade.
460
- *
461
- * This is the type accepted by {@link setGlobalWidgetConfig} and all provider props.
462
- * It intentionally excludes `initResponse`, which is populated automatically by the
463
- * provider after a successful fetch and must never be set manually.
464
- *
465
- * The `null` vs `undefined` distinction on `widgetToken` and `organizationId` is intentional:
466
- * - `undefined` — not set at this level; inherit from the nearest ancestor or global store.
467
- * - `null` — explicitly cleared; downstream sees "no value" even if an ancestor had one
468
- * (e.g. after logout or deliberate de-scoping).
469
- *
470
- * @see {@link WidgetConfig} for the resolved output type (includes `initResponse`)
471
- * @see {@link RootWidgetProvider}
472
- * @see {@link WidgetProvider}
473
- * @see {@link setGlobalWidgetConfig}
474
- */
475
- interface WidgetConfigInput {
476
- /**
477
- * Base URL of the Tesouro embedded API (e.g. `"https://api.tesouro.com"`).
478
- *
479
- * When omitted the nearest ancestor's `baseUrl` or the global store value is used.
480
- * Changing this recreates the underlying HTTP client so all subsequent requests
481
- * go to the new host.
482
- */
483
- baseUrl?: BaseUrl;
484
- /**
485
- * Bearer token used to authenticate widget requests.
486
- *
487
- * Injected as `Authorization: Bearer <token>` on every outgoing request via an
488
- * interceptor on the scoped HTTP client. Token updates are picked up immediately
489
- * without recreating the client.
490
- *
491
- * - `string` — send this token on all requests from this level downward.
492
- * - `null` — explicitly cleared; no auth header is sent and fetching is suppressed.
493
- * - `undefined` — not set at this level; inherit from the nearest ancestor or global store.
494
- */
495
- widgetToken?: string | null;
496
- /**
497
- * Organization ID forwarded as the `x-organization-id` request header.
498
- *
499
- * Passed through {@link EmbedApiProvider} context rather than the auth interceptor,
500
- * so individual data-access hooks can opt in per-request.
501
- *
502
- * - `string` — use this organization for downstream data requests.
503
- * - `null` — explicitly cleared; queries that require an org ID will be disabled.
504
- * - `undefined` — not set at this level; inherit from the nearest ancestor or global store.
505
- *
506
- * When `undefined` across the **whole** cascade (no prop, no ancestor, no global
507
- * value), the resolved org defaults to the loaded `initResponse.organizationId`
508
- * (see {@link WidgetConfig.initResponse}) once the widget-init fetch settles. This
509
- * is the lowest-priority fallback — any explicit `string` or `null` at any cascade
510
- * level wins, and an explicit `null` is preserved and never falls back.
511
- *
512
- * Only an **explicit** ancestor org is inherited. An ancestor's *init-derived*
513
- * default does not propagate into a descendant that owns its own fetch (its own
514
- * `baseUrl`/`widgetToken`); such a descendant defaults to its own
515
- * `initResponse.organizationId` instead, so it never sends an ancestor's org with
516
- * its own token.
517
- */
518
- organizationId?: string | null;
519
- /**
520
- * Optional post-creation hook for the scoped HTTP client.
521
- *
522
- * Called once after the provider creates its scoped {@link EmbeddedClient} and
523
- * applies the built-in `Authorization: Bearer` interceptor. Receives the
524
- * fully-configured client and must return the client to be used for the lifetime of
525
- * this provider level — either the same instance (with additional interceptors
526
- * attached) or a new client entirely.
527
- *
528
- * **Order:** The built-in auth interceptor is always applied first. `configClient`
529
- * is called on top of it, so any interceptors you add here run after auth is set.
530
- *
531
- * **Any prop triggers a scoped client.** A {@link WidgetProvider} creates its own
532
- * scoped client whenever any prop is set — including `configClient` alone, without
533
- * `baseUrl` or `widgetToken`. Only a fully props-free pass-through provider skips
534
- * client creation and never calls this function.
535
- *
536
- * **Stability:** The function reference is included in the client creation memo's
537
- * dependency array. Passing an unstable (inline) function recreates the client on
538
- * every render. Stabilize with `useCallback` or define the function outside the
539
- * component.
540
- *
541
- * **Cascade:** Inherits from the nearest ancestor when `undefined`. A child
542
- * {@link WidgetProvider} that creates its own scoped client will use the resolved
543
- * `configClient` from the cascade unless it provides its own override.
544
- *
545
- * @example
546
- * ```tsx
547
- * const addLogging = useCallback(
548
- * (client: EmbeddedClient) => {
549
- * client.interceptors.request.use((req) => {
550
- * console.log('[widget]', req.method, req.url);
551
- * return req;
552
- * });
553
- * return client;
554
- * },
555
- * [],
556
- * );
557
- *
558
- * <RootWidgetProvider
559
- * baseUrl="https://api.tesouro.com"
560
- * widgetToken={token}
561
- * configClient={addLogging}
562
- * >
563
- * <App />
564
- * </RootWidgetProvider>
565
- * ```
566
- */
567
- configClient?: (client: EmbeddedClient) => EmbeddedClient;
568
- /**
569
- * Overrides the widget-gateway routing decision for the scoped HTTP client.
570
- *
571
- * Any caller reaching the Tesouro API with a widget token must route data
572
- * requests through the widget gateway: prefix the path with
573
- * `/api/widget-gateway/proxy` and carry the token as `X-Widget-Token`. The
574
- * provider applies both automatically per request when the request origin is
575
- * a known Tesouro API host (`WIDGET_GATEWAY_HOSTS`, derived from the
576
- * generated `ClientOptions['baseUrl']`); `/api/widget-gateway/*` paths (the
577
- * init round-trip) always pass through untouched.
578
- *
579
- * - `undefined` — decide from the request origin, as above. Inherits from
580
- * the nearest ancestor or global store like every other config field.
581
- * - `true` — always apply the rewrite, even for an unlisted base URL (e.g. a
582
- * custom domain in front of the gateway).
583
- * - `false` — never apply it. For hosts that route widget requests their own
584
- * way, such as a same-origin BFF whose `configClient` retargets every
585
- * request.
586
- *
587
- * Independent of {@link configClient}: a host that only adds a header keeps
588
- * the built-in routing, and the built-in interceptor runs before any
589
- * `configClient` interceptor.
590
- */
591
- gatewayRouting?: boolean;
592
- /**
593
- * Component the embedded widgets should render in place of plain `<a>` tags.
594
- *
595
- * Pass e.g. Next.js's `Link` to make in-app navigation use the host router.
596
- * Cascades like other config: provider prop > nearest ancestor > global store.
597
- * When no value is set anywhere, widgets fall back to a plain `<a>` element.
598
- */
599
- linkComponent?: LinkComponent;
600
- /**
601
- * Which UI framework the widget UI layer should render with.
602
- *
603
- * Lets a consuming context bind widgets to either the shadcn/Tailwind or the
604
- * Tecton implementation behind the same outward-facing API. The selection is
605
- * a presentation concern only — it cascades through the provider tree exactly
606
- * like {@link linkComponent} and is read by UI libraries via `useUIFramework`;
607
- * it never appears in any widget's feature-library or component props.
608
- *
609
- * - `'shadcn'` — the shadcn/Tailwind implementation.
610
- * - `'tecton'` — the Tecton implementation.
611
- * - `null` / `undefined` — not set at this level; inherit from the nearest
612
- * ancestor or global store, falling back to `shadcn` when unset everywhere.
613
- * `shadcn` is the implicit default, so existing consumers need no changes.
614
- */
615
- uiFramework?: UIFramework | null;
616
- /**
617
- * Which implementation a widget renders with.
618
- *
619
- * Lets a consuming context bind widgets to either the Tesouro-native or the
620
- * Monite SDK implementation behind the same outward-facing API. It cascades
621
- * through the provider tree exactly like {@link linkComponent} and
622
- * {@link uiFramework} — provider prop > nearest ancestor > global store — and
623
- * is read via `useImplementation`.
624
- *
625
- * - `'native'` — the Tesouro-native implementation.
626
- * - `'monite'` — the Monite SDK implementation.
627
- * - `null` / `undefined` — not set at this level; inherit from the nearest
628
- * ancestor or global store, falling back to `native` when unset everywhere.
629
- * `native` is the implicit default, so existing consumers need no changes.
630
- */
631
- implementation?: Implementation | null;
632
- }
633
- /**
634
- * Props shared by every analytics-owner-capable widget provider.
635
- *
636
- * Combines the full settable cascade ({@link WidgetConfigInput}) with the
637
- * analytics opt-out honored by analytics owners. Both {@link RootWidgetProvider}
638
- * and {@link WidgetProvider} build their public props on top of this; the latter
639
- * adds error-boundary props of its own.
640
- *
641
- * @see {@link WidgetConfigInput} for per-field cascade and `null` vs omitted semantics
642
- */
643
- interface WidgetProviderBaseProps extends WidgetConfigInput {
644
- /**
645
- * Opt out of all analytics capture and prevent PostHog from loading. Default `true`.
646
- *
647
- * Honored only by an analytics **owner** — a {@link RootWidgetProvider} or a
648
- * standalone {@link WidgetProvider} with no parent provider. When `false`,
649
- * owner-bound `track` calls in this subtree become no-ops and the PostHog
650
- * installer is never dynamically imported for this owner's environment.
651
- * Setting it on a nested {@link WidgetProvider} is ignored in v1 (a one-time
652
- * `console.warn` is emitted to make the no-op discoverable).
653
- */
654
- analytics?: boolean;
655
- }
656
-
657
- /**
658
- * Copy for the states `WidgetProvider` renders *itself*, in place of the widget:
659
- * the error-boundary fallback and the disclosures gate. A host overrides any
660
- * subset through the `providerLabels` prop, which cascades like
661
- * `disclosuresAcceptance`.
662
- *
663
- * Not named `Labels` on the public surface: a widget's own `labels` prop is a
664
- * different thing, and these two travel together on every widget's props type.
665
- */
666
- interface WidgetProviderLabels {
667
- /** Default copy for the built-in error boundary fallback. */
668
- errorBoundaryFallback: string;
669
- /** Heading when init reports disclosures are required and not yet accepted. */
670
- disclosuresRequiredTitle: string;
671
- /** Heading while a token-only refresh leaves init stale for the live token. */
672
- disclosuresRefreshingTitle: string;
673
- /** Supporting copy while the accept action is withheld for a stale init. */
674
- disclosuresRefreshingDescription: string;
675
- }
676
-
677
- /**
678
- * Props for {@link WidgetProvider}.
679
- *
680
- * All fields are optional. When **all** are omitted the provider is a transparent
681
- * pass-through: no fetch is issued and all resolved values cascade unchanged from
682
- * the nearest ancestor.
683
- */
684
- interface WidgetProviderProps extends WidgetProviderBaseProps {
685
- /**
686
- * Fallback rendered when a render-time exception is caught inside this
687
- * provider's subtree. Pass either a `ReactNode` (rendered directly) or a
688
- * render-prop receiving `{ error, resetErrorBoundary }` from
689
- * `react-error-boundary`. Default is a plain `role="alert"` div whose copy
690
- * comes from `providerLabels.errorBoundaryFallback`.
691
- */
692
- errorFallback?: ReactNode | ((props: FallbackProps) => ReactNode);
693
- /**
694
- * Called once when the boundary catches an error, before the fallback
695
- * renders. Use for telemetry / Sentry / partner logging. Exceptions
696
- * thrown from `onError` propagate per `react-error-boundary` semantics.
697
- */
698
- onError?: (error: unknown, info: ErrorInfo) => void;
699
- /**
700
- * Accept surface shown when the caller owes disclosures — an INVITED
701
- * teammate (including `NOT_REQUIRED` orgs, who still need Accept to
702
- * activate) or an ACTIVE user who owes a new version. Pass
703
- * `<AcceptDisclosuresWidget />`. Cascades like `linkComponent`.
704
- * WidgetProvider cannot import the widget itself (cycle).
705
- */
706
- disclosuresAcceptance?: ReactNode;
707
- /**
708
- * Overrides for the copy this provider renders in place of the widget: the
709
- * built-in error-boundary fallback and the disclosures gate. Any subset;
710
- * unlisted keys keep their defaults. Cascades like `linkComponent`.
711
- *
712
- * Named `providerLabels` rather than `labels` because a widget's own
713
- * `labels` prop sits alongside this one on the same props type.
714
- */
715
- providerLabels?: Partial<WidgetProviderLabels>;
716
- }
717
-
718
- interface CreateCardFeatureLabels {
719
- toast: {
720
- creating: string;
721
- success: string;
722
- error: string;
723
- /**
724
- * Card issued but a follow-up velocity-control POST failed. The card
725
- * already exists; this must not read as a create failure.
726
- */
727
- controlsWarning: string;
728
- /**
729
- * Card issued but granting company admins access to it failed. The card
730
- * already exists; this must not read as a create failure.
731
- */
732
- companyAdminAccessWarning: string;
733
- /**
734
- * Card issued, but BOTH the velocity-control POST(s) and the company-admin
735
- * access grant failed. Distinct from the two single-failure warnings above
736
- * so an issuer who hits both is told about both, not just whichever this
737
- * code checks first.
738
- */
739
- controlsAndAccessWarning: string;
740
- /**
741
- * The roster of users to grant access to a new card failed to load.
742
- * Shown with a retry action; Create stays disabled until it resolves so
743
- * a card is never issued without its required admin grants.
744
- */
745
- debitCardIssuersError: string;
746
- retry: string;
747
- };
748
- untitledFundingAccount: string;
749
- /**
750
- * API-required `name` on a velocity control. Not shown in this widget;
751
- * may surface on a later controls list.
752
- */
753
- velocityControlNames: {
754
- spendLimit: string;
755
- perTransactionMaximum: string;
756
- };
757
- /**
758
- * Spend-limit reset-period tab labels and notices. Owned here (not UI
759
- * labels) because the feature layer decides what each opaque period value
760
- * means.
761
- */
762
- spendLimit: {
763
- periodOneTime: string;
764
- periodDaily: string;
765
- periodMonthly: string;
766
- oneTimeWarningTitle: string;
767
- oneTimeWarningDescription: string;
768
- dailyResetNotice: string;
769
- monthlyResetNotice: string;
770
- };
771
- /**
772
- * Success-screen copy chosen from the create response's `cardStatus`.
773
- * Active/ready wording lives on the UI defaults; these cover statuses that
774
- * must not claim the card is already usable.
775
- */
776
- success: {
777
- pendingActivationTitle: string;
778
- pendingActivationDescription: string;
779
- createdTitle: string;
780
- createdDescription: string;
781
- };
782
- }
783
- declare const CREATE_CARD_FEATURE_LABELS_EN: CreateCardFeatureLabels;
784
- declare function resolveCreateCardFeatureLabels(overrides?: Partial<{
785
- toast: Partial<CreateCardFeatureLabels['toast']>;
786
- untitledFundingAccount: string;
787
- velocityControlNames: Partial<CreateCardFeatureLabels['velocityControlNames']>;
788
- spendLimit: Partial<CreateCardFeatureLabels['spendLimit']>;
789
- success: Partial<CreateCardFeatureLabels['success']>;
790
- }>): CreateCardFeatureLabels;
791
-
792
- type CreateCardWidgetProps = WidgetProviderProps & {
793
- /** Static card plastic image URL (no overlays). Host / white-label supplied. */
794
- cardArtSrc: string;
795
- labels?: PartialDeep<CreateCardWidgetLabels>;
796
- featureLabels?: Partial<{
797
- toast: Partial<CreateCardFeatureLabels['toast']>;
798
- untitledFundingAccount: string;
799
- velocityControlNames: Partial<CreateCardFeatureLabels['velocityControlNames']>;
800
- spendLimit: Partial<CreateCardFeatureLabels['spendLimit']>;
801
- success: Partial<CreateCardFeatureLabels['success']>;
802
- }>;
803
- className?: string;
804
- onClose?: () => void;
805
- onCancel?: () => void;
806
- /** Fired with the new debit card id after a successful create. */
807
- onViewCard?: (cardId: string) => void;
808
- };
809
- /**
810
- * Self-contained Create Card widget. Issues a debit card via the Embed API and
811
- * drives setup → preparing → success with sonner toasts for the mutation.
812
- */
813
- declare function CreateCardWidget({ baseUrl, widgetToken, organizationId, configClient, gatewayRouting, linkComponent, implementation, uiFramework, errorFallback, onError, analytics, disclosuresAcceptance, providerLabels, ...innerProps }: CreateCardWidgetProps): React.JSX.Element;
814
-
815
- /** Opaque UI format values — mapped to API `DebitCardType` in the feature. */
816
- declare const CardFormatValue: {
817
- readonly Virtual: "virtual";
818
- readonly Physical: "physical";
819
- };
820
- type CardFormatValue = (typeof CardFormatValue)[keyof typeof CardFormatValue];
821
-
822
- export { CREATE_CARD_FEATURE_LABELS_EN, CardFormatValue, CreateCardWidget, resolveCreateCardFeatureLabels };
823
- export type { CreateCardFeatureLabels, CreateCardWidgetLabels, CreateCardWidgetProps };