@capitalos/react 1.1.0-rc.1 → 1.2.1-rc.1
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/README.md +4 -0
- package/dist/_tsup-dts-rollup.d.mts +381 -41
- package/dist/_tsup-dts-rollup.d.ts +381 -41
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/src/index.d.mts +11 -0
- package/dist/src/index.d.ts +11 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -50,3 +50,7 @@ function MyComponent() {
|
|
|
50
50
|
## TypeScript support
|
|
51
51
|
|
|
52
52
|
TypeScript definitions for `@capitalos/react` are built into the npm package and should be automatically picked up by your editor.
|
|
53
|
+
|
|
54
|
+
## Error Handling
|
|
55
|
+
|
|
56
|
+
For details on how errors are managed within the SDK and how to handle them as a consumer or a maintainer, please see our [Error Handling Guidelines](./ERROR_HANDLING.md).
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Connection } from 'penpal';
|
|
1
2
|
import { IFrameComponent } from 'iframe-resizer';
|
|
2
3
|
import { IFrameMessageData } from 'iframe-resizer';
|
|
3
4
|
import { IFrameOptions } from 'iframe-resizer';
|
|
@@ -5,6 +6,7 @@ import { IFrameResizedData } from 'iframe-resizer';
|
|
|
5
6
|
import { IFrameScrollData } from 'iframe-resizer';
|
|
6
7
|
import { default as React_2 } from 'react';
|
|
7
8
|
import { ReactNode } from 'react';
|
|
9
|
+
import { RefObject } from 'react';
|
|
8
10
|
import { z } from 'zod';
|
|
9
11
|
import * as z_2 from 'zod';
|
|
10
12
|
|
|
@@ -30,6 +32,34 @@ export declare type AccountStatus = z_2.infer<typeof accountStatusSchema>;
|
|
|
30
32
|
|
|
31
33
|
declare const accountStatusSchema: z_2.ZodEnum<["eligible", "ineligible", "engaged", "onboarding", "approved", "processing", "pending", "declined", "closed", "waiting"]>;
|
|
32
34
|
|
|
35
|
+
export declare type ActionResult<T = void> = {
|
|
36
|
+
success: true;
|
|
37
|
+
canceled: false;
|
|
38
|
+
data: T;
|
|
39
|
+
} | {
|
|
40
|
+
success: false;
|
|
41
|
+
canceled: true;
|
|
42
|
+
} | {
|
|
43
|
+
success: false;
|
|
44
|
+
canceled: false;
|
|
45
|
+
error: CapitalOSError;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export declare const ActionsIframeContext: React_2.Context<ActionsIframeContextValue | null>;
|
|
49
|
+
|
|
50
|
+
declare interface ActionsIframeContextValue {
|
|
51
|
+
childFunctions: ChildFunctions | null;
|
|
52
|
+
actions: {
|
|
53
|
+
freezeCard: (cardId: string) => Promise<ActionResult<Card>>;
|
|
54
|
+
unfreezeCard: (cardId: string) => Promise<ActionResult<Card>>;
|
|
55
|
+
} | null;
|
|
56
|
+
isLoading: boolean;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export declare function ActionsIframeProvider({ children }: {
|
|
60
|
+
children: React_2.ReactNode;
|
|
61
|
+
}): JSX.Element;
|
|
62
|
+
|
|
33
63
|
declare type AllowedExitPoints = {
|
|
34
64
|
welcome: 'application' | 'activation';
|
|
35
65
|
application: 'application' | 'activation';
|
|
@@ -71,6 +101,10 @@ declare type CapitalOsAuthenticationContextType = {
|
|
|
71
101
|
* The authentication flow will automatically refresh the token after invalidation.
|
|
72
102
|
*/
|
|
73
103
|
invalidateToken: () => void;
|
|
104
|
+
/**
|
|
105
|
+
* Optional flag indicating whether to log events to the console.
|
|
106
|
+
*/
|
|
107
|
+
enableLogging: boolean;
|
|
74
108
|
};
|
|
75
109
|
|
|
76
110
|
declare const CapitalOsAuthenticationProvider: React_2.FC<ProviderProps>;
|
|
@@ -90,7 +124,7 @@ export declare class CapitalOSError extends Error {
|
|
|
90
124
|
|
|
91
125
|
declare type CapitalOsProps<T extends CapitalOsRenderingContext> = CommonProps & {
|
|
92
126
|
renderingContext: T;
|
|
93
|
-
methods?: Partial<
|
|
127
|
+
methods?: Partial<ParentFunctions>;
|
|
94
128
|
sizeWidth?: boolean;
|
|
95
129
|
};
|
|
96
130
|
|
|
@@ -99,6 +133,10 @@ export declare type CapitalOsRenderingContext = {
|
|
|
99
133
|
referer?: string;
|
|
100
134
|
};
|
|
101
135
|
|
|
136
|
+
export declare type Card = {
|
|
137
|
+
status: 'active' | 'inactive' | 'canceled' | 'frozen';
|
|
138
|
+
};
|
|
139
|
+
|
|
102
140
|
export declare type CardApiDto = z_2.infer<typeof cardApiDtoSchema>;
|
|
103
141
|
|
|
104
142
|
declare const cardApiDtoSchema: z_2.ZodObject<{
|
|
@@ -187,7 +225,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
|
|
|
187
225
|
limit?: number | undefined;
|
|
188
226
|
};
|
|
189
227
|
}>;
|
|
190
|
-
allowedSpendCategories: z_2.ZodArray<z_2.ZodEnum<["airlines", "carRental", "carService", "education", "electronics", "gasPump", "gasStation", "generalMerchandise", "government", "hardwareAndConstruction", "insurance", "legal", "lodging", "medical", "other", "parking", "phoneAndInternet", "professionalServices", "recreationAndEntertainment", "restaurants", "shipping", "software", "taxisAndRideshare", "transportation", "travelMisc", "utilities"]>, "many">;
|
|
228
|
+
allowedSpendCategories: z_2.ZodArray<z_2.ZodEnum<["advertisingAndMarketing", "airlines", "carRental", "carService", "education", "electronics", "gasPump", "gasStation", "generalMerchandise", "government", "hardwareAndConstruction", "insurance", "legal", "lodging", "medical", "other", "parking", "phoneAndInternet", "professionalServices", "recreationAndEntertainment", "restaurants", "shipping", "software", "taxisAndRideshare", "transportation", "travelMisc", "utilities"]>, "many">;
|
|
191
229
|
allowedMerchants: z_2.ZodArray<z_2.ZodObject<{
|
|
192
230
|
id: z_2.ZodUnion<[z_2.ZodString, z_2.ZodString]>;
|
|
193
231
|
name: z_2.ZodString;
|
|
@@ -206,7 +244,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
|
|
|
206
244
|
shipment: z_2.ZodObject<{
|
|
207
245
|
address: z_2.ZodObject<{
|
|
208
246
|
addressLine1: z_2.ZodString;
|
|
209
|
-
addressLine2: z_2.ZodOptional<z_2.ZodNullable<z_2.ZodString
|
|
247
|
+
addressLine2: z_2.ZodOptional<z_2.ZodNullable<z_2.ZodEffects<z_2.ZodNullable<z_2.ZodString>, string | null, string | null>>>;
|
|
210
248
|
city: z_2.ZodString;
|
|
211
249
|
state: z_2.ZodEffects<z_2.ZodString, string, string>;
|
|
212
250
|
zipcode: z_2.ZodString;
|
|
@@ -330,7 +368,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
|
|
|
330
368
|
limit?: number | undefined;
|
|
331
369
|
};
|
|
332
370
|
};
|
|
333
|
-
allowedSpendCategories: ("airlines" | "carRental" | "carService" | "education" | "electronics" | "gasPump" | "gasStation" | "generalMerchandise" | "government" | "hardwareAndConstruction" | "insurance" | "legal" | "lodging" | "medical" | "other" | "parking" | "phoneAndInternet" | "professionalServices" | "recreationAndEntertainment" | "restaurants" | "shipping" | "software" | "taxisAndRideshare" | "transportation" | "travelMisc" | "utilities")[];
|
|
371
|
+
allowedSpendCategories: ("advertisingAndMarketing" | "airlines" | "carRental" | "carService" | "education" | "electronics" | "gasPump" | "gasStation" | "generalMerchandise" | "government" | "hardwareAndConstruction" | "insurance" | "legal" | "lodging" | "medical" | "other" | "parking" | "phoneAndInternet" | "professionalServices" | "recreationAndEntertainment" | "restaurants" | "shipping" | "software" | "taxisAndRideshare" | "transportation" | "travelMisc" | "utilities")[];
|
|
334
372
|
allowedMerchants: {
|
|
335
373
|
id: string;
|
|
336
374
|
name: string;
|
|
@@ -385,7 +423,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
|
|
|
385
423
|
limit?: number | undefined;
|
|
386
424
|
};
|
|
387
425
|
};
|
|
388
|
-
allowedSpendCategories: ("airlines" | "carRental" | "carService" | "education" | "electronics" | "gasPump" | "gasStation" | "generalMerchandise" | "government" | "hardwareAndConstruction" | "insurance" | "legal" | "lodging" | "medical" | "other" | "parking" | "phoneAndInternet" | "professionalServices" | "recreationAndEntertainment" | "restaurants" | "shipping" | "software" | "taxisAndRideshare" | "transportation" | "travelMisc" | "utilities")[];
|
|
426
|
+
allowedSpendCategories: ("advertisingAndMarketing" | "airlines" | "carRental" | "carService" | "education" | "electronics" | "gasPump" | "gasStation" | "generalMerchandise" | "government" | "hardwareAndConstruction" | "insurance" | "legal" | "lodging" | "medical" | "other" | "parking" | "phoneAndInternet" | "professionalServices" | "recreationAndEntertainment" | "restaurants" | "shipping" | "software" | "taxisAndRideshare" | "transportation" | "travelMisc" | "utilities")[];
|
|
389
427
|
allowedMerchants: {
|
|
390
428
|
id: string;
|
|
391
429
|
name: string;
|
|
@@ -435,6 +473,24 @@ export declare type CardDetailsProps = CommonProps & {
|
|
|
435
473
|
*/
|
|
436
474
|
export declare function CardsApp(props: CommonProps): JSX.Element;
|
|
437
475
|
|
|
476
|
+
export declare type ChildFunctions = {
|
|
477
|
+
freezeCard: (cardId: string) => Promise<ClientActionResult<Card>>;
|
|
478
|
+
unfreezeCard: (cardId: string) => Promise<ClientActionResult<Card>>;
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
export declare type ClientActionResult<T> = {
|
|
482
|
+
success: true;
|
|
483
|
+
canceled: false;
|
|
484
|
+
data: T;
|
|
485
|
+
} | {
|
|
486
|
+
success: false;
|
|
487
|
+
canceled: true;
|
|
488
|
+
} | {
|
|
489
|
+
success: false;
|
|
490
|
+
canceled: false;
|
|
491
|
+
error: string;
|
|
492
|
+
};
|
|
493
|
+
|
|
438
494
|
export declare type CommonProps = {
|
|
439
495
|
/**
|
|
440
496
|
* The token provided by initiate-login.
|
|
@@ -462,6 +518,13 @@ export declare type CommonProps = {
|
|
|
462
518
|
theme?: ThemeColorScheme;
|
|
463
519
|
};
|
|
464
520
|
|
|
521
|
+
export declare function ContactSupport({ onDone, onCancel, ...restOfProps }: ContactSupportProps): JSX.Element;
|
|
522
|
+
|
|
523
|
+
export declare type ContactSupportProps = CommonProps & {
|
|
524
|
+
onDone: () => void;
|
|
525
|
+
onCancel: () => void;
|
|
526
|
+
};
|
|
527
|
+
|
|
465
528
|
export declare function decodeOneTimeToken(token: string): any;
|
|
466
529
|
|
|
467
530
|
/**
|
|
@@ -517,40 +580,6 @@ export declare const ErrorCode: {
|
|
|
517
580
|
|
|
518
581
|
export declare type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
|
|
519
582
|
|
|
520
|
-
export declare type IframeConnectionMethods = {
|
|
521
|
-
onLoad: () => void;
|
|
522
|
-
onError: (error: RawErrorDetails) => void;
|
|
523
|
-
/**
|
|
524
|
-
* Called when the iframe detects that the JWT token has expired.
|
|
525
|
-
* This triggers the token refresh flow, which will obtain a new token
|
|
526
|
-
* and reload the iframe with the fresh token.
|
|
527
|
-
*/
|
|
528
|
-
onTokenExpired?: () => void;
|
|
529
|
-
createCard?: {
|
|
530
|
-
onDone?: () => void;
|
|
531
|
-
onCancel?: () => void;
|
|
532
|
-
};
|
|
533
|
-
createDispute?: {
|
|
534
|
-
onDone?: () => void;
|
|
535
|
-
onCancel?: () => void;
|
|
536
|
-
};
|
|
537
|
-
onboarding?: {
|
|
538
|
-
onDone?: (account: Account) => void;
|
|
539
|
-
};
|
|
540
|
-
tokenExchange?: {
|
|
541
|
-
onLongLivedToken?: (jwtToken: string) => void;
|
|
542
|
-
};
|
|
543
|
-
makePayment?: {
|
|
544
|
-
onDone?: () => void;
|
|
545
|
-
};
|
|
546
|
-
devTools?: {
|
|
547
|
-
onClose?: () => void;
|
|
548
|
-
};
|
|
549
|
-
cardDetails?: {
|
|
550
|
-
onCardCanceled?: () => void;
|
|
551
|
-
};
|
|
552
|
-
};
|
|
553
|
-
|
|
554
583
|
export declare const IframeResizer: React_2.ForwardRefExoticComponent<Omit<IFrameOptions, "closedCallback" | "scrollCallback" | "resizedCallback" | "messageCallback" | "initCallback"> & {
|
|
555
584
|
onClosed?(iframeId: string): void;
|
|
556
585
|
onInit?(iframe: IFrameComponent): void;
|
|
@@ -648,6 +677,22 @@ export declare type IssueCardProps = CommonProps & {
|
|
|
648
677
|
onCancel: () => void;
|
|
649
678
|
};
|
|
650
679
|
|
|
680
|
+
export declare function LegalDocuments({ onDone, ...restOfProps }: LegalDocumentsProps): JSX.Element;
|
|
681
|
+
|
|
682
|
+
export declare type LegalDocumentsProps = CommonProps & {
|
|
683
|
+
onDone: () => void;
|
|
684
|
+
};
|
|
685
|
+
|
|
686
|
+
export declare const logger: {
|
|
687
|
+
log: (message: string, options?: LoggerOptions) => void;
|
|
688
|
+
warn: (message: string, options?: LoggerOptions) => void;
|
|
689
|
+
error: (message: string, options?: LoggerOptions) => void;
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
declare type LoggerOptions = {
|
|
693
|
+
enableLogging: boolean | undefined;
|
|
694
|
+
};
|
|
695
|
+
|
|
651
696
|
/**
|
|
652
697
|
* Renders the CapitalOS Make a Payment experience.
|
|
653
698
|
*/
|
|
@@ -660,6 +705,81 @@ export declare type MakePaymentProps = CommonProps & {
|
|
|
660
705
|
onDone: () => void;
|
|
661
706
|
};
|
|
662
707
|
|
|
708
|
+
export declare function Mfa({ onDone, onCancel, mfaId, destination, codeLength, canResendAfter, operationName, ...restOfProps }: MfaProps): JSX.Element;
|
|
709
|
+
|
|
710
|
+
export declare type MfaActionResult = ActionResult<void>;
|
|
711
|
+
|
|
712
|
+
export declare type MfaProps = CommonProps & {
|
|
713
|
+
/**
|
|
714
|
+
* The ID of the MFA request.
|
|
715
|
+
*/
|
|
716
|
+
mfaId: string;
|
|
717
|
+
/**
|
|
718
|
+
* The destination of the MFA request.
|
|
719
|
+
*/
|
|
720
|
+
destination: string;
|
|
721
|
+
/**
|
|
722
|
+
* The length of the code to be entered.
|
|
723
|
+
*/
|
|
724
|
+
codeLength: number;
|
|
725
|
+
/**
|
|
726
|
+
* ISO string representation of DateTime in UTC
|
|
727
|
+
*/
|
|
728
|
+
canResendAfter: string;
|
|
729
|
+
/**
|
|
730
|
+
* The name of the operation that is being performed.
|
|
731
|
+
*/
|
|
732
|
+
operationName?: string;
|
|
733
|
+
/**
|
|
734
|
+
* Callback to invoke when the MFA was successfully completed.
|
|
735
|
+
*/
|
|
736
|
+
onDone: () => void;
|
|
737
|
+
/**
|
|
738
|
+
* Callback to invoke when the MFA was cancelled by the user.
|
|
739
|
+
*/
|
|
740
|
+
onCancel: () => void;
|
|
741
|
+
};
|
|
742
|
+
|
|
743
|
+
export declare interface MfaRequestContext {
|
|
744
|
+
mfaId: string;
|
|
745
|
+
destination: string;
|
|
746
|
+
codeLength: number;
|
|
747
|
+
canResendAfter: string;
|
|
748
|
+
operationName?: string;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
export declare interface MfaResult {
|
|
752
|
+
success: boolean;
|
|
753
|
+
canceled?: boolean;
|
|
754
|
+
error?: string;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
declare interface MfaState {
|
|
758
|
+
context: MfaRequestContext;
|
|
759
|
+
resolve: (result: MfaActionResult) => void;
|
|
760
|
+
reject: (error: Error) => void;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* Generic modal component that displays content with backdrop/blur
|
|
765
|
+
*/
|
|
766
|
+
export declare function Modal({ onClose, children, ariaLabel }: ModalProps): JSX.Element;
|
|
767
|
+
|
|
768
|
+
export declare interface ModalProps {
|
|
769
|
+
/**
|
|
770
|
+
* Callback when modal should be closed (backdrop click)
|
|
771
|
+
*/
|
|
772
|
+
onClose: () => void;
|
|
773
|
+
/**
|
|
774
|
+
* Content to render inside the modal
|
|
775
|
+
*/
|
|
776
|
+
children: ReactNode;
|
|
777
|
+
/**
|
|
778
|
+
* Accessible label for screen readers
|
|
779
|
+
*/
|
|
780
|
+
ariaLabel?: string;
|
|
781
|
+
}
|
|
782
|
+
|
|
663
783
|
export declare function Onboarding<T extends OnboardingEntryPoint>({ onDone, entryPoint: onboardingEntryPoint, exitPoint: onboardingExitPoint, ...restOfProps }: OnboardingProps<T>): JSX.Element;
|
|
664
784
|
|
|
665
785
|
declare type OnboardingEntryPoint = keyof AllowedExitPoints;
|
|
@@ -670,6 +790,65 @@ declare type OnboardingProps<T extends keyof AllowedExitPoints> = CommonProps &
|
|
|
670
790
|
onDone: (account: Account) => void;
|
|
671
791
|
};
|
|
672
792
|
|
|
793
|
+
export declare type ParentFunctions = {
|
|
794
|
+
onLoad: () => void;
|
|
795
|
+
onError: (error: RawErrorDetails) => void;
|
|
796
|
+
/**
|
|
797
|
+
* Called when the iframe detects that the JWT token has expired.
|
|
798
|
+
* This triggers the token refresh flow, which will obtain a new token
|
|
799
|
+
* and reload the iframe with the fresh token.
|
|
800
|
+
*/
|
|
801
|
+
onTokenExpired?: () => void;
|
|
802
|
+
cardDetails?: {
|
|
803
|
+
onCardCanceled?: () => void;
|
|
804
|
+
};
|
|
805
|
+
contactSupport?: {
|
|
806
|
+
onDone?: () => void;
|
|
807
|
+
onCancel?: () => void;
|
|
808
|
+
};
|
|
809
|
+
createCard?: {
|
|
810
|
+
onDone?: () => void;
|
|
811
|
+
onCancel?: () => void;
|
|
812
|
+
};
|
|
813
|
+
createDispute?: {
|
|
814
|
+
onDone?: () => void;
|
|
815
|
+
onCancel?: () => void;
|
|
816
|
+
};
|
|
817
|
+
devTools?: {
|
|
818
|
+
onClose?: () => void;
|
|
819
|
+
};
|
|
820
|
+
legalDocuments?: {
|
|
821
|
+
onDone?: () => void;
|
|
822
|
+
};
|
|
823
|
+
makePayment?: {
|
|
824
|
+
onDone?: () => void;
|
|
825
|
+
};
|
|
826
|
+
mfa?: {
|
|
827
|
+
onDone?: () => void;
|
|
828
|
+
onCancel?: () => void;
|
|
829
|
+
};
|
|
830
|
+
onboarding?: {
|
|
831
|
+
onDone?: (account: Account) => void;
|
|
832
|
+
};
|
|
833
|
+
replaceCard?: {
|
|
834
|
+
onDone?: () => void;
|
|
835
|
+
onClose?: () => void;
|
|
836
|
+
};
|
|
837
|
+
'system-messages'?: {
|
|
838
|
+
requestMfa?: (context: MfaRequestContext) => Promise<MfaResult>;
|
|
839
|
+
};
|
|
840
|
+
statements?: {
|
|
841
|
+
onDone?: () => void;
|
|
842
|
+
};
|
|
843
|
+
terminateCard?: {
|
|
844
|
+
onDone?: () => void;
|
|
845
|
+
onClose?: () => void;
|
|
846
|
+
};
|
|
847
|
+
tokenExchange?: {
|
|
848
|
+
onLongLivedToken?: (jwtToken: string) => void;
|
|
849
|
+
};
|
|
850
|
+
};
|
|
851
|
+
|
|
673
852
|
declare type ProviderProps = {
|
|
674
853
|
getToken: () => Promise<string>;
|
|
675
854
|
enableLogging?: boolean | undefined;
|
|
@@ -828,6 +1007,69 @@ declare const renderingContextSchema: z.ZodIntersection<z.ZodDiscriminatedUnion<
|
|
|
828
1007
|
entryPoint: "devTools";
|
|
829
1008
|
}, {
|
|
830
1009
|
entryPoint: "devTools";
|
|
1010
|
+
}>, z.ZodObject<{
|
|
1011
|
+
entryPoint: z.ZodLiteral<"contactSupport">;
|
|
1012
|
+
}, "strip", z.ZodTypeAny, {
|
|
1013
|
+
entryPoint: "contactSupport";
|
|
1014
|
+
}, {
|
|
1015
|
+
entryPoint: "contactSupport";
|
|
1016
|
+
}>, z.ZodObject<{
|
|
1017
|
+
entryPoint: z.ZodLiteral<"statements">;
|
|
1018
|
+
}, "strip", z.ZodTypeAny, {
|
|
1019
|
+
entryPoint: "statements";
|
|
1020
|
+
}, {
|
|
1021
|
+
entryPoint: "statements";
|
|
1022
|
+
}>, z.ZodObject<{
|
|
1023
|
+
entryPoint: z.ZodLiteral<"legalDocuments">;
|
|
1024
|
+
}, "strip", z.ZodTypeAny, {
|
|
1025
|
+
entryPoint: "legalDocuments";
|
|
1026
|
+
}, {
|
|
1027
|
+
entryPoint: "legalDocuments";
|
|
1028
|
+
}>, z.ZodObject<{
|
|
1029
|
+
entryPoint: z.ZodLiteral<"replaceCard">;
|
|
1030
|
+
cardId: z.ZodString;
|
|
1031
|
+
}, "strip", z.ZodTypeAny, {
|
|
1032
|
+
cardId: string;
|
|
1033
|
+
entryPoint: "replaceCard";
|
|
1034
|
+
}, {
|
|
1035
|
+
cardId: string;
|
|
1036
|
+
entryPoint: "replaceCard";
|
|
1037
|
+
}>, z.ZodObject<{
|
|
1038
|
+
entryPoint: z.ZodLiteral<"terminateCard">;
|
|
1039
|
+
cardId: z.ZodString;
|
|
1040
|
+
}, "strip", z.ZodTypeAny, {
|
|
1041
|
+
cardId: string;
|
|
1042
|
+
entryPoint: "terminateCard";
|
|
1043
|
+
}, {
|
|
1044
|
+
cardId: string;
|
|
1045
|
+
entryPoint: "terminateCard";
|
|
1046
|
+
}>, z.ZodObject<{
|
|
1047
|
+
entryPoint: z.ZodLiteral<"actions">;
|
|
1048
|
+
}, "strip", z.ZodTypeAny, {
|
|
1049
|
+
entryPoint: "actions";
|
|
1050
|
+
}, {
|
|
1051
|
+
entryPoint: "actions";
|
|
1052
|
+
}>, z.ZodObject<{
|
|
1053
|
+
entryPoint: z.ZodLiteral<"mfa">;
|
|
1054
|
+
mfaId: z.ZodString;
|
|
1055
|
+
destination: z.ZodString;
|
|
1056
|
+
codeLength: z.ZodNumber;
|
|
1057
|
+
canResendAfter: z.ZodString;
|
|
1058
|
+
operationName: z.ZodOptional<z.ZodString>;
|
|
1059
|
+
}, "strip", z.ZodTypeAny, {
|
|
1060
|
+
entryPoint: "mfa";
|
|
1061
|
+
mfaId: string;
|
|
1062
|
+
destination: string;
|
|
1063
|
+
codeLength: number;
|
|
1064
|
+
canResendAfter: string;
|
|
1065
|
+
operationName?: string | undefined;
|
|
1066
|
+
}, {
|
|
1067
|
+
entryPoint: "mfa";
|
|
1068
|
+
mfaId: string;
|
|
1069
|
+
destination: string;
|
|
1070
|
+
codeLength: number;
|
|
1071
|
+
canResendAfter: string;
|
|
1072
|
+
operationName?: string | undefined;
|
|
831
1073
|
}>]>, z.ZodObject<{
|
|
832
1074
|
referer: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
833
1075
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -836,11 +1078,33 @@ declare const renderingContextSchema: z.ZodIntersection<z.ZodDiscriminatedUnion<
|
|
|
836
1078
|
referer?: string | null | undefined;
|
|
837
1079
|
}>>;
|
|
838
1080
|
|
|
1081
|
+
export declare function ReplaceCard({ cardId, onDone, onClose, ...restOfProps }: ReplaceCardProps): JSX.Element;
|
|
1082
|
+
|
|
1083
|
+
export declare type ReplaceCardProps = CommonProps & {
|
|
1084
|
+
cardId: string;
|
|
1085
|
+
onDone: () => void;
|
|
1086
|
+
onClose: () => void;
|
|
1087
|
+
};
|
|
1088
|
+
|
|
839
1089
|
/**
|
|
840
1090
|
* Safely decodes a URL component, handling potential errors
|
|
841
1091
|
*/
|
|
842
1092
|
export declare function safeDecodeURIComponent(str: string): string;
|
|
843
1093
|
|
|
1094
|
+
export declare function Statements({ onDone, ...restOfProps }: StatementsProps): JSX.Element;
|
|
1095
|
+
|
|
1096
|
+
export declare type StatementsProps = CommonProps & {
|
|
1097
|
+
onDone: () => void;
|
|
1098
|
+
};
|
|
1099
|
+
|
|
1100
|
+
export declare function TerminateCard({ cardId, onDone, onClose, ...restOfProps }: TerminateCardProps): JSX.Element;
|
|
1101
|
+
|
|
1102
|
+
export declare type TerminateCardProps = CommonProps & {
|
|
1103
|
+
cardId: string;
|
|
1104
|
+
onDone: () => void;
|
|
1105
|
+
onClose: () => void;
|
|
1106
|
+
};
|
|
1107
|
+
|
|
844
1108
|
export declare type ThemeColorScheme = 'light' | 'dark' | 'system';
|
|
845
1109
|
|
|
846
1110
|
export declare type TokenData = {
|
|
@@ -892,8 +1156,61 @@ export declare enum TokenType {
|
|
|
892
1156
|
longLived = "longLived"
|
|
893
1157
|
}
|
|
894
1158
|
|
|
1159
|
+
/**
|
|
1160
|
+
* Hook to access the actions iframe functions.
|
|
1161
|
+
*
|
|
1162
|
+
* @returns An object containing the actions functions and loading state
|
|
1163
|
+
* @throws {CapitalOSError} If the hook is used outside of a CapitalOS component
|
|
1164
|
+
*
|
|
1165
|
+
* @example
|
|
1166
|
+
* ```tsx
|
|
1167
|
+
* const { actions, isLoading } = useActions()
|
|
1168
|
+
*
|
|
1169
|
+
* if (isLoading) {
|
|
1170
|
+
* return <LoadingSpinner />
|
|
1171
|
+
* }
|
|
1172
|
+
*
|
|
1173
|
+
* // Use the actions
|
|
1174
|
+
* await actions.freezeCard()
|
|
1175
|
+
* ```
|
|
1176
|
+
*/
|
|
1177
|
+
export declare function useActions(): {
|
|
1178
|
+
actions: ChildFunctions | null;
|
|
1179
|
+
isLoading: boolean;
|
|
1180
|
+
};
|
|
1181
|
+
|
|
895
1182
|
export declare const useCapitalOsAuthContext: () => CapitalOsAuthenticationContextType;
|
|
896
1183
|
|
|
1184
|
+
/**
|
|
1185
|
+
* Hook to resolve logging preference, with direct prop taking precedence over context.
|
|
1186
|
+
* @param enableLoggingProp Direct prop for enableLogging.
|
|
1187
|
+
* @returns Effective logging flag.
|
|
1188
|
+
*/
|
|
1189
|
+
export declare function useEnableLogging(enableLoggingProp?: boolean): boolean;
|
|
1190
|
+
|
|
1191
|
+
/**
|
|
1192
|
+
* A React hook that manages the iframe connection lifecycle, including:
|
|
1193
|
+
* - Establishing and maintaining the iframe connection
|
|
1194
|
+
* - Handling token expiration and refresh flows
|
|
1195
|
+
* - Managing loading states
|
|
1196
|
+
* - Coordinating between one-time tokens and context-based authentication
|
|
1197
|
+
* - Providing error handling and logging capabilities
|
|
1198
|
+
*/
|
|
1199
|
+
export declare function useIframe(props: {
|
|
1200
|
+
renderingContext: CapitalOsRenderingContext;
|
|
1201
|
+
oneTimeToken?: string | undefined;
|
|
1202
|
+
enableLogging?: boolean | undefined;
|
|
1203
|
+
onError?: ((error: Error) => void) | undefined;
|
|
1204
|
+
theme?: ThemeColorScheme | undefined;
|
|
1205
|
+
methods?: Partial<Omit<ParentFunctions, 'onLoad' | 'onError' | 'onTokenExpired'>> | undefined;
|
|
1206
|
+
}): {
|
|
1207
|
+
isLoaded: boolean;
|
|
1208
|
+
url: string | undefined;
|
|
1209
|
+
tokenData: TokenData | undefined;
|
|
1210
|
+
iframeRef: RefObject<HTMLIFrameElement>;
|
|
1211
|
+
connection: Connection<ChildFunctions> | null;
|
|
1212
|
+
};
|
|
1213
|
+
|
|
897
1214
|
/**
|
|
898
1215
|
* connects to child iframe and returns whether the iframe is loaded or not.
|
|
899
1216
|
* token was added to the list of dependencies to make sure that the connection is re-established when the token changes.
|
|
@@ -902,9 +1219,12 @@ export declare function useIframeConnection({ iframeRef, token, onError, methods
|
|
|
902
1219
|
iframeRef: React.RefObject<HTMLIFrameElement>;
|
|
903
1220
|
token: string | undefined;
|
|
904
1221
|
onError: ((error: Error) => void) | undefined | null;
|
|
905
|
-
methods:
|
|
906
|
-
}):
|
|
1222
|
+
methods: ParentFunctions;
|
|
1223
|
+
}): Connection<ChildFunctions> | null;
|
|
907
1224
|
|
|
1225
|
+
/**
|
|
1226
|
+
* returns a memoized url of the iframe or undefined if the token is not available yet.
|
|
1227
|
+
*/
|
|
908
1228
|
export declare function useIframeUrl({ tokenData, renderingContext, theme, onError, }: {
|
|
909
1229
|
tokenData: TokenData | undefined;
|
|
910
1230
|
renderingContext: CapitalOsRenderingContext;
|
|
@@ -912,4 +1232,24 @@ export declare function useIframeUrl({ tokenData, renderingContext, theme, onErr
|
|
|
912
1232
|
onError?: ((error: Error) => void) | undefined;
|
|
913
1233
|
}): string | undefined;
|
|
914
1234
|
|
|
1235
|
+
/**
|
|
1236
|
+
* Hook that provides stable logging functions (log, warn, error), scoped to the resolved enableLogging flag.
|
|
1237
|
+
* @param enableLoggingProp Optional direct prop to override logging.
|
|
1238
|
+
*/
|
|
1239
|
+
export declare function useLogger(enableLoggingProp?: boolean): {
|
|
1240
|
+
log: (message: string) => void;
|
|
1241
|
+
warn: (message: string) => void;
|
|
1242
|
+
error: (message: string) => void;
|
|
1243
|
+
};
|
|
1244
|
+
|
|
1245
|
+
export declare function useMfaState(): {
|
|
1246
|
+
activeMfaRequest: MfaState | null;
|
|
1247
|
+
isMfaActive: boolean;
|
|
1248
|
+
mfaContext: MfaRequestContext | null;
|
|
1249
|
+
requestMfa: (context: MfaRequestContext) => Promise<MfaActionResult>;
|
|
1250
|
+
handleMfaDone: () => void;
|
|
1251
|
+
handleMfaCancel: () => void;
|
|
1252
|
+
handleMfaError: (error: CapitalOSError) => void;
|
|
1253
|
+
};
|
|
1254
|
+
|
|
915
1255
|
export { }
|