@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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.tsx","../../src/capital-os.tsx","../../src/context/capital-os-authentication-context.tsx","../../src/common/token-exchange-iframe.tsx","../../src/error.ts","../../src/hooks.ts","../../package.json","../../src/utils.ts","../../src/iframe-resizer.tsx","../../src/dev-tools.tsx","../../src/components/dev-tools-button.tsx"],"sourcesContent":["'use client'\n\nimport React, { useMemo } from 'react'\n\nimport { CapitalOS } from './capital-os'\nimport { CapitalOsAuthenticationProvider } from './context/capital-os-authentication-context'\nimport { DevTools } from './dev-tools'\nimport type { EntryPoint, IssueCardDefaultValues } from './external-types'\nimport type { Account, CommonProps } from './types'\n\n// #region App\n/**\n * Renders the CapitalOS CardsApp.\n */\nexport function CardsApp(props: CommonProps) {\n const entryPoint: EntryPoint = 'cardsApp'\n const renderingContext = useMemo(() => ({ entryPoint }), [entryPoint])\n return <CapitalOS {...props} renderingContext={renderingContext} />\n}\n// #endregion\n\n// maintain backwards compatibility\n\n/** @deprecated Use {@link CardsApp} instead */\nconst App = CardsApp\n\nexport { App }\n\n// #region Issue Card\nexport type IssueCardProps = CommonProps & {\n /**\n * Default values to prefill the form with.\n *\n * Either provide a userId, in which case the default values will be taken from that user's profile, or provide the cardholder's details directly.\n */\n cardholder?: IssueCardDefaultValues\n\n /**\n * Callback to invoke when the card was created successfully.\n */\n onDone: () => void\n\n /**\n * Callback to invoke when the card creation was cancelled by the user.\n */\n onCancel: () => void\n}\n\n/**\n * Renders the CapitalOS Issue Card experience.\n */\nexport function IssueCard({ cardholder, onDone, onCancel, ...restOfProps }: IssueCardProps) {\n const entryPoint: EntryPoint = 'createCard'\n const renderingContext = useMemo(\n () => ({\n entryPoint,\n cardholder,\n }),\n [cardholder],\n )\n\n return (\n <CapitalOS {...restOfProps} renderingContext={renderingContext} methods={{ createCard: { onDone, onCancel } }} />\n )\n}\n// #endregion\n\n// #region Dispute Transaction\nexport type DisputeTransactionProps = CommonProps & {\n /**\n * The ID of the transaction to dispute.\n */\n transactionId: string\n\n /**\n * Callback to invoke when the dispute was successfully submitted.\n */\n onDone: () => void\n\n /**\n * Callback to invoke when the user cancels the dispute submission.\n */\n onCancel: () => void\n}\n\n/**\n * Renders the CapitalOS Dispute Transaction experience.\n */\nexport function DisputeTransaction({ transactionId, onDone, onCancel, ...restOfProps }: DisputeTransactionProps) {\n const entryPoint: EntryPoint = 'createDispute'\n const renderingContext = useMemo(() => ({ entryPoint, transactionId }), [transactionId])\n\n return (\n <CapitalOS {...restOfProps} renderingContext={renderingContext} methods={{ createDispute: { onDone, onCancel } }} />\n )\n}\n// #endregion\n\n// #region Bill Payment Dashboard\nexport type BillPayAppProps = CommonProps\n\n/**\n * Renders the CapitalOS Bill Payment Dashboard experience.\n */\nexport function BillPayApp(props: BillPayAppProps) {\n const entryPoint: EntryPoint = 'billPayApp'\n const renderingContext = useMemo(() => ({ entryPoint }), [entryPoint])\n\n return <CapitalOS {...props} renderingContext={renderingContext} />\n}\n// #endregion\n\n// #region Card Details\nexport type CardDetailsProps = CommonProps & {\n /**\n * The ID of the card to manage.\n */\n cardId: string\n cardOnly?: boolean | undefined\n hideAddress?: boolean | undefined\n onCardCanceled?: () => void\n}\n\n/**\n * Renders the CapitalOS Manage Card experience.\n */\nexport function CardDetails(props: CardDetailsProps) {\n const { onCardCanceled, ...restOfProps } = props\n const entryPoint: EntryPoint = 'cardDetails'\n const renderingContext = useMemo(\n () => ({ entryPoint, cardId: props.cardId, cardOnly: props.cardOnly, hideAddress: props.hideAddress }),\n [entryPoint, props.cardId, props.cardOnly],\n )\n\n return (\n <CapitalOS\n {...restOfProps}\n renderingContext={renderingContext}\n methods={{ cardDetails: { onCardCanceled: onCardCanceled ?? (() => {}) } }}\n />\n )\n}\n// #endregion\n\n// #region Account Details\nexport type AccountDetailsProps = CommonProps\n\n/**\n * Renders the CapitalOS Account Details experience.\n */\nexport function AccountDetails(props: AccountDetailsProps) {\n const entryPoint: EntryPoint = 'accountDetails'\n const renderingContext = useMemo(() => ({ entryPoint }), [entryPoint])\n\n return <CapitalOS {...props} renderingContext={renderingContext} />\n}\n// #endregion\n\n// #region Account Actions\nexport type AccountActionsProps = CommonProps\n\n/**\n * Renders the CapitalOS Account Actions experience.\n */\nexport function AccountActions(props: AccountActionsProps) {\n const entryPoint: EntryPoint = 'accountActions'\n const renderingContext = useMemo(() => ({ entryPoint }), [entryPoint])\n\n return <CapitalOS {...props} renderingContext={renderingContext} />\n}\n// #endregion\n\n// #region Insights Dashboard\nexport type InsightsDashboardProps = CommonProps\n\n/**\n * Renders the CapitalOS Insights Dashboard experience\n */\nexport function InsightsDashboard(props: InsightsDashboardProps) {\n const entryPoint: EntryPoint = 'insightsDashboard'\n const renderingContext = useMemo(() => ({ entryPoint }), [entryPoint])\n\n return <CapitalOS {...props} renderingContext={renderingContext} />\n}\n// #endregion\n\n// #region Insights Widget\nexport type InsightsWidgetProps = CommonProps & {\n /**\n * The specific widget to render.\n * naming convention:\n * 1. Over-time Widgets\n * over-time-{metric}-by-{dimension}-per-{time-granularity}\n * 2. Top/Ranking Widgets\n * top-{entities}-by-{metric}-{timeframe}\n * 3. Comparison Widgets\n * comparison-{metric}-{primary-timeframe}-vs-{secondary-timeframe}\n */\n widget:\n | 'over-time-spend-by-card-per-month'\n | 'over-time-spend-by-category-per-month'\n | 'top-cards-by-spend-this-month'\n | 'top-categories-by-spend-this-month'\n | 'top-transactions-by-amount-this-month'\n | 'comparison-spend-this-month-vs-last-month'\n /**\n * Whether to hide the title of the widget.\n */\n hideTitle?: boolean | undefined\n /**\n * The height of the widget.\n */\n height?: number | undefined\n /**\n * The width of the widget.\n */\n width?: number | undefined\n}\n\n/**\n * Renders a specific CapitalOS Insights Widget\n */\nexport function InsightsWidget(props: InsightsWidgetProps) {\n const entryPoint: EntryPoint = 'insightsWidget'\n const { widget, hideTitle, height, width } = props\n const renderingContext = useMemo(\n () => ({ entryPoint, widget, hideTitle, height, width }),\n [entryPoint, widget, hideTitle, height, width],\n )\n\n return <CapitalOS {...props} renderingContext={renderingContext} />\n}\n// #endregion\n\n// #region Onboarding\ntype AllowedExitPoints = {\n welcome: 'application' | 'activation'\n application: 'application' | 'activation'\n}\n\ntype OnboardingEntryPoint = keyof AllowedExitPoints\ntype OnboardingProps<T extends keyof AllowedExitPoints> = CommonProps & {\n entryPoint?: T\n exitPoint?: AllowedExitPoints[T]\n onDone: (account: Account) => void\n}\n\nexport function Onboarding<T extends OnboardingEntryPoint>({\n onDone,\n entryPoint: onboardingEntryPoint,\n exitPoint: onboardingExitPoint,\n ...restOfProps\n}: OnboardingProps<T>) {\n // This component uses 'entryPoint' in two distinct ways:\n // 1. As a prop to control the user's starting/ending stages of onboarding\n // 2. For internal rendering context to determine which client component to display\n const entryPoint: EntryPoint = 'onboarding'\n const renderingContext = useMemo(\n () => ({ entryPoint, onboardingEntryPoint, onboardingExitPoint }),\n [entryPoint, onboardingEntryPoint, onboardingExitPoint],\n )\n\n return <CapitalOS {...restOfProps} renderingContext={renderingContext} methods={{ onboarding: { onDone } }} />\n}\n// #endregion\n\n// #region Make a payment\nexport type MakePaymentProps = CommonProps & {\n /**\n * Callback to invoke when the payment was made successfully.\n */\n onDone: () => void\n}\n\n/**\n * Renders the CapitalOS Make a Payment experience.\n */\nexport function MakePayment({ onDone, ...restOfProps }: MakePaymentProps) {\n const entryPoint: EntryPoint = 'makePayment'\n const renderingContext = useMemo(() => ({ entryPoint }), [entryPoint])\n\n return <CapitalOS {...restOfProps} renderingContext={renderingContext} methods={{ makePayment: { onDone } }} />\n}\n// #endregion\n\n// #region Dev Tools\nexport { DevTools }\n// #endregion\n\n// #region Authentication provider\nexport { CapitalOsAuthenticationProvider }\n// #endregion\n","import React, { useEffect, useMemo, useRef, useState, useCallback } from 'react'\n\nimport { useCapitalOsAuthContext } from './context/capital-os-authentication-context'\nimport { CapitalOSError, ErrorCode } from './error'\nimport { IframeConnectionMethods, useIframeConnection, useIframeUrl } from './hooks'\nimport { IframeResizer } from './iframe-resizer'\nimport { CommonProps, CapitalOsRenderingContext, TokenData } from './types'\nimport { tokenDataFromOneTimeToken } from './utils'\n\ntype CapitalOsProps<T extends CapitalOsRenderingContext> = CommonProps & {\n renderingContext: T\n methods?: Partial<IframeConnectionMethods>\n sizeWidth?: boolean\n}\n\n/**\n * The internal component that handles all the heavy lifting of connecting to the iframe and rendering the app.\n * all user facing components are basically a syntactic sugar on top of this.\n */\nexport function CapitalOS<T extends CapitalOsRenderingContext>(props: CapitalOsProps<T>) {\n const {\n token: tokenProp,\n className,\n enableLogging,\n onError,\n loadingComponent: LoadingComponent,\n renderingContext,\n methods,\n theme,\n sizeWidth,\n } = props\n const { tokenData: contextTokenData, error, invalidateToken } = useCapitalOsAuthContext()\n // represents the state of whether all required react queries returned and the page should be visible\n const [isLoaded, setIsLoaded] = useState(false)\n const iframeRef = useRef<HTMLIFrameElement>(null)\n useErrorHandling(error, onError)\n\n const tokenData: TokenData | undefined = useMemo(\n () => (tokenProp ? tokenDataFromOneTimeToken(tokenProp) : contextTokenData),\n [tokenProp, contextTokenData],\n )\n\n // Handle token expiration by invalidating the token\n // The context's useEffect will automatically handle the refresh\n const handleTokenExpired = useCallback(() => {\n if (enableLogging) {\n // eslint-disable-next-line no-console\n console.log('CapitalOS: Token expired, invalidating...')\n }\n\n // If we're using tokenProp, we can't refresh automatically\n if (tokenProp) {\n onError?.(\n new CapitalOSError({\n message: 'Token expired. Cannot automatically refresh when using token prop.',\n code: ErrorCode.unauthorized,\n }),\n )\n return\n }\n\n // Use the invalidateToken function from the context\n // This will clear the token and the authentication context's useEffect will handle the refresh\n invalidateToken()\n\n // The iframe will be reloaded automatically when tokenData changes\n setIsLoaded(false)\n }, [tokenProp, invalidateToken, enableLogging, onError])\n\n useEffect(() => {\n if (tokenProp && contextTokenData && enableLogging) {\n // eslint-disable-next-line no-console\n console.warn(\n 'CapitalOS: token was provided both from provider and from the token prop. the prop will take precedence',\n )\n }\n }, [tokenProp, contextTokenData, enableLogging])\n\n const url = useIframeUrl({ tokenData, renderingContext, theme, onError })\n\n useIframeConnection({\n iframeRef,\n token: tokenData?.token,\n onError: (error) => {\n onError?.(error)\n // when connection fails it's probably a handshake timeout with the iframe. we will stop showing the loader\n // since the fact we failed communication doesn't necessarily mean the iframe didn't load\n setIsLoaded(true)\n },\n methods: {\n onLoad: () => {\n setIsLoaded(true)\n },\n onError: (error) => {\n const err = new CapitalOSError(error)\n onError?.(err)\n },\n onTokenExpired: handleTokenExpired,\n ...methods,\n },\n })\n\n if (!tokenData || !url) {\n return <>{LoadingComponent || null}</>\n }\n\n // insightsWidget does not need additional padding. also - it supports a height property that needs to be respected.\n const shouldAddPaddingBottom = renderingContext.entryPoint !== 'insightsWidget'\n\n return (\n <>\n {/* show loader as long as we're not loaded */}\n {!isLoaded && LoadingComponent}\n {/* hide the iframe as long as we're not loaded */}\n <IframeResizer\n src={url}\n allow=\"clipboard-write\"\n checkOrigin={false}\n style={{ width: '1px', height: '0px', minWidth: '100%' }}\n className={className}\n log={!!enableLogging}\n ref={iframeRef}\n hidden={!isLoaded}\n // Add a constant offset to the height of the iframe to account for css shadows.\n // This is useful for tooltips that are rendered with shadows below them that extend beyond the bottom of the tooltip.\n onResized={(data) => {\n if (!shouldAddPaddingBottom) {\n return\n }\n\n // typing is wrong here. this is a string.\n const newHeight = `${parseInt(data.height as unknown as string) + 12}px`\n data.iframe.style.height = newHeight\n }}\n sizeWidth={sizeWidth}\n />\n </>\n )\n}\n\n/**\n * Makes sure component only fires the error event once.\n * @param error - The error to handle.\n * @param onError - The function to call when the error occurs.\n */\nfunction useErrorHandling(error: Error | null | undefined, onError?: (error: Error) => void) {\n const errorFired = useRef(false)\n\n useEffect(() => {\n if (error && !errorFired.current) {\n onError?.(error)\n errorFired.current = true\n }\n }, [error, onError])\n}\n","'use client'\n\nimport React, { createContext, useContext, useState, useMemo, useCallback, useEffect } from 'react'\n\nimport { TokenExchangeIframe } from '../common/token-exchange-iframe'\nimport { CapitalOSError, ErrorCode } from '../error'\nimport { TokenData, TokenParamKey, TokenParamLocation, TokenType } from '../types'\nimport { decodeOneTimeToken } from '../utils'\n\ntype CapitalOsAuthenticationContextType = {\n tokenData?: TokenData | undefined\n isLoading: boolean\n error?: Error | undefined\n /**\n * Invalidates the current token..\n * This is used when the iframe signals that the token has expired.\n * The authentication flow will automatically refresh the token after invalidation.\n */\n invalidateToken: () => void\n}\n\ntype ProviderProps = {\n getToken: () => Promise<string>\n enableLogging?: boolean | undefined\n children: React.ReactNode\n}\n\nconst CapitalOsAuthenticationContext = createContext<CapitalOsAuthenticationContextType>({\n isLoading: false,\n invalidateToken: () => {},\n})\n\nexport const CapitalOsAuthenticationProvider: React.FC<ProviderProps> = ({ getToken, enableLogging, children }) => {\n const [oneTimeToken, setOneTimeToken] = useState<string | undefined>(undefined)\n const [baseUrl, setBaseUrl] = useState<string | undefined>(undefined)\n const [longLivedToken, setLongLivedToken] = useState<string | undefined>(undefined)\n const [isLoading, setIsLoading] = useState(false)\n const [error, setError] = useState<Error | undefined>(undefined)\n\n const refreshOneTimeToken = useCallback(async () => {\n setIsLoading(true)\n try {\n const newToken = await getToken()\n setOneTimeToken(newToken)\n setError(undefined)\n const tokenObject = decodeOneTimeToken(newToken)\n const url = new URL(tokenObject.path)\n // we don't need the /login part of the path since long lived tokens don't go through the login flow.\n url.pathname = ''\n setBaseUrl(url.toString())\n } catch (error) {\n setError(error as Error)\n } finally {\n setIsLoading(false)\n }\n }, [getToken])\n\n // Add invalidateToken method\n const invalidateToken = useCallback(() => {\n setLongLivedToken(undefined)\n }, [])\n\n // On mount, if no long-lived token is available, refresh to get a one-time token.\n useEffect(() => {\n if (!longLivedToken) {\n refreshOneTimeToken()\n }\n }, [longLivedToken, refreshOneTimeToken])\n\n const onExchangeComplete = useCallback((jwtToken: string) => {\n setLongLivedToken(jwtToken)\n setOneTimeToken(undefined)\n setError(undefined)\n }, [])\n\n const contextValue: CapitalOsAuthenticationContextType = useMemo(() => {\n if (longLivedToken && !baseUrl) {\n throw new CapitalOSError({\n message: 'baseUrl is required for long lived tokens',\n code: ErrorCode.unauthorized,\n })\n }\n const tokenData: TokenData | undefined = longLivedToken\n ? ({\n token: longLivedToken,\n tokenType: TokenType.longLived,\n baseUrl: baseUrl!,\n paramKey: TokenParamKey.accessToken,\n paramLocation: TokenParamLocation.hash,\n } as const)\n : undefined\n\n return {\n tokenData,\n isLoading,\n error,\n invalidateToken,\n }\n }, [longLivedToken, isLoading, error, invalidateToken, baseUrl])\n\n return (\n <>\n <CapitalOsAuthenticationContext.Provider value={contextValue}>{children}</CapitalOsAuthenticationContext.Provider>\n {oneTimeToken && !longLivedToken && (\n <TokenExchangeIframe\n oneTimeToken={oneTimeToken}\n onExchangeComplete={onExchangeComplete}\n enableLogging={enableLogging}\n onExchangeError={setError}\n />\n )}\n </>\n )\n}\n\nexport const useCapitalOsAuthContext = () => useContext(CapitalOsAuthenticationContext)\n","import React, { useMemo, useRef } from 'react'\n\nimport { CapitalOSError } from '../error'\nimport { useIframeConnection, useIframeUrl } from '../hooks'\nimport { IframeResizer } from '../iframe-resizer'\nimport { tokenDataFromOneTimeToken } from '../utils'\n\nexport interface TokenExchangeIframeProps {\n oneTimeToken: string\n enableLogging?: boolean | undefined\n onExchangeComplete: (jwtToken: string) => void\n onExchangeError?: (error: Error) => void\n}\n\n/**\n * The component is hidden from the user and is only used to exchange a one-time token for a JWT in the authentication context.\n *\n * The token exchange process works as follows:\n * 1. Component renders a hidden iframe with the one-time token in the URL\n * 2. The iframe loads with the long-lived token as part of its url redirect response and establishes a secure connection with the parent window\n * 3. The iframe passes the long-lived token to the parent via postMessage\n * 4. onExchangeComplete callback is triggered with the new JWT\n *\n * If any errors occur during this process, they are passed to onExchangeError.\n */\nexport function TokenExchangeIframe(props: TokenExchangeIframeProps) {\n const { oneTimeToken, enableLogging, onExchangeComplete, onExchangeError } = props\n\n const iframeRef = useRef<HTMLIFrameElement>(null)\n\n const tokenData = useMemo(() => tokenDataFromOneTimeToken(oneTimeToken), [oneTimeToken])\n\n const renderingContext = {\n entryPoint: 'tokenExchange',\n } as const\n\n const url = useIframeUrl({\n tokenData,\n onError: onExchangeError,\n renderingContext,\n })\n\n useIframeConnection({\n iframeRef,\n token: oneTimeToken,\n onError: onExchangeError,\n methods: {\n onLoad: () => {},\n onError: (error) => {\n onExchangeError?.(new CapitalOSError(error))\n },\n tokenExchange: {\n onLongLivedToken: onExchangeComplete,\n },\n },\n })\n\n // Render the hidden iframe.\n return (\n <IframeResizer\n src={url}\n checkOrigin={false}\n style={{ display: 'none' }} // Hidden from view\n log={!!enableLogging}\n ref={iframeRef}\n />\n )\n}\n","/**\n * Base class for all SDK errors\n */\nexport class CapitalOSError extends Error {\n code: ErrorCode\n constructor({ message, code }: { message: string; code: ErrorCode }) {\n super(message)\n this.name = 'CapitalOSError'\n this.code = code\n }\n}\n\nexport const ErrorCode = {\n unauthorized: 'unauthorized',\n invalid_account_status: 'invalid_account_status',\n unsupported_entry_point: 'unsupported_entry_point',\n internal_error: 'internal_error',\n} as const\n\nexport type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode]\n\n/**\n * Represents an error that occurs when an invalid token is encountered.\n */\nexport class InvalidTokenError extends CapitalOSError {\n constructor(message?: string) {\n super({ message: `Invalid token ${message ?? ''}`, code: ErrorCode.unauthorized })\n this.name = 'CapitalOSInvalidTokenError'\n }\n}\n\nexport class TokenRefreshError extends CapitalOSError {\n constructor(originalError?: Error) {\n super({\n message: `Failed to refresh token: ${originalError?.message}`,\n code: ErrorCode.unauthorized,\n })\n this.name = 'CapitalOSTokenRefreshError'\n }\n}\n","import { connectToChild } from 'penpal'\nimport { useEffect, useMemo, useRef } from 'react'\n\nimport { ErrorCode } from './error'\nimport { Account, ThemeColorScheme, CapitalOsRenderingContext, TokenData } from './types'\nimport { buildIframeUrl } from './utils'\n\nconst IFRAME_CONNECTION_TIMEOUT_MILLISECONDS = 10_000\n\n/**\n * An error type providing a reason code and message.\n * Penpal only passes plain objects, so this does not inherit from Error.\n */\nexport type RawErrorDetails = {\n code: ErrorCode\n message: string\n}\n\nexport type IframeConnectionMethods = {\n onLoad: () => void\n onError: (error: RawErrorDetails) => void\n /**\n * Called when the iframe detects that the JWT token has expired.\n * This triggers the token refresh flow, which will obtain a new token\n * and reload the iframe with the fresh token.\n */\n onTokenExpired?: () => void\n createCard?: {\n onDone?: () => void\n onCancel?: () => void\n }\n createDispute?: {\n onDone?: () => void\n onCancel?: () => void\n }\n onboarding?: {\n onDone?: (account: Account) => void\n }\n tokenExchange?: {\n onLongLivedToken?: (jwtToken: string) => void\n }\n makePayment?: {\n onDone?: () => void\n }\n devTools?: {\n onClose?: () => void\n }\n cardDetails?: {\n onCardCanceled?: () => void\n }\n}\n\n/**\n * connects to child iframe and returns whether the iframe is loaded or not.\n * token was added to the list of dependencies to make sure that the connection is re-established when the token changes.\n */\nexport function useIframeConnection({\n iframeRef,\n token,\n onError,\n methods,\n}: {\n iframeRef: React.RefObject<HTMLIFrameElement>\n token: string | undefined\n onError: ((error: Error) => void) | undefined | null\n methods: IframeConnectionMethods\n}) {\n // connect to child iframe\n useEffect(() => {\n if (!iframeRef.current) {\n return\n }\n\n const connection = connectToChild({\n iframe: iframeRef.current,\n childOrigin: '*',\n debug: true,\n timeout: IFRAME_CONNECTION_TIMEOUT_MILLISECONDS,\n methods,\n })\n\n connection.promise.catch((error) => {\n onError?.(error)\n })\n\n return () => {\n connection.destroy()\n }\n }, [token, iframeRef])\n}\n\nexport function useIframeUrl({\n tokenData,\n renderingContext,\n theme,\n onError,\n}: {\n tokenData: TokenData | undefined\n renderingContext: CapitalOsRenderingContext\n theme?: ThemeColorScheme | undefined\n onError?: ((error: Error) => void) | undefined\n}) {\n // We assume that onError and renderingContext do not change over the lifetime of the component.\n // We put it in a ref to avoid causing unnecessary re-renders.\n const onErrorRef = useRef(onError)\n const renderingContextRef = useRef(renderingContext)\n\n return useMemo(() => {\n if (!tokenData) {\n return undefined\n }\n return buildIframeUrl({\n tokenData,\n renderingContext: renderingContextRef.current,\n theme,\n onError: onErrorRef.current,\n })\n // wrapped rendering context in a ref since we do not want to reload the iframe unless the token changes.\n }, [tokenData, theme, onErrorRef, renderingContextRef])\n}\n","{\n \"name\": \"@capitalos/react\",\n \"version\": \"1.1.0-rc.1\",\n \"description\": \"integrate CapitalOS into your react app\",\n \"main\": \"dist/index.js\",\n \"module\": \"dist/esm/index.js\",\n \"types\": \"dist/_tsup-dts-rollup.d.ts\",\n \"scripts\": {\n \"build\": \" pnpm lint && tsup src/index.tsx --experimental-dts --minify --format esm,cjs --clean --no-splitting --sourcemap --legacy-output --out-dir dist\",\n \"dev\": \"pnpm build --watch\",\n \"prepublishOnly\": \"pnpm build\",\n \"lint\": \"eslint . --ext .ts,.tsx --fix\",\n \"lint-ci\": \"eslint . --ext .ts,.tsx\"\n },\n \"keywords\": [\n \"capitalos\",\n \"react\"\n ],\n \"homepage\": \"https://docs.capitalos.com/docs/using-react-client-library\",\n \"author\": \"CapitalOS\",\n \"license\": \"MIT\",\n \"files\": [\n \"dist\",\n \"package.json\"\n ],\n \"devDependencies\": {\n \"@changesets/cli\": \"^2.27.12\",\n \"@microsoft/api-extractor\": \"^7.39.5\",\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/iframe-resizer\": \"^3.5.13\",\n \"@types/react\": \"18.0.20\",\n \"@typescript-eslint/eslint-plugin\": \"^7.2.0\",\n \"@typescript-eslint/parser\": \"^7.2.0\",\n \"eslint\": \"^8.57.0\",\n \"eslint-config-prettier\": \"^9.1.0\",\n \"eslint-plugin-prettier\": \"^5.1.3\",\n \"eslint-plugin-react\": \"^7.34.0\",\n \"prettier\": \"^3.2.5\",\n \"react\": \"16.8.0\",\n \"tsup\": \"^8.1.0\",\n \"typescript\": \"^5.6.2\"\n },\n \"dependencies\": {\n \"iframe-resizer\": \"^4.3.9\",\n \"penpal\": \"^6.2.2\"\n },\n \"peerDependencies\": {\n \"react\": \">=16.8.0\"\n }\n}\n","import { version as sdkVersion } from '../package.json'\nimport { InvalidTokenError } from './error'\nimport {\n ThemeColorScheme,\n CapitalOsRenderingContext,\n TokenData,\n TokenType,\n TokenParamKey,\n TokenParamLocation,\n} from './types'\n\n/**\n * Encodes the rendering context as base64 and then URI encodes it.\n */\nexport function encodeRenderingContext<T>(renderingContext: NonNullable<T>) {\n const renderingContextJson = JSON.stringify(renderingContext)\n const renderingContextBase64 = btoa(renderingContextJson)\n const renderingContextEncoded = encodeURIComponent(renderingContextBase64)\n\n return renderingContextEncoded\n}\n\nexport function decodeOneTimeToken(token: string) {\n try {\n const urlDecodedToken = decodeURIComponent(token)\n const base64DecodedToken = atob(urlDecodedToken)\n return JSON.parse(base64DecodedToken)\n } catch (error) {\n throw new InvalidTokenError()\n }\n}\n\n/**\n * Safely decodes a URL component, handling potential errors\n */\nexport function safeDecodeURIComponent(str: string): string {\n try {\n return decodeURIComponent(str)\n } catch (e) {\n // If decoding fails, it might not have been encoded, so return original\n return str\n }\n}\n\n/**\n * Builds the iframe url from token data, rendering context, and theme.\n */\nexport function buildIframeUrl({\n tokenData,\n renderingContext,\n theme,\n onError,\n}: {\n tokenData: TokenData\n renderingContext: CapitalOsRenderingContext\n theme?: ThemeColorScheme | undefined\n onError?: ((error: Error) => void) | undefined\n}) {\n try {\n const enrichedRenderingContext = renderingContext\n ? {\n ...renderingContext,\n referer: window.location.href,\n }\n : null\n\n const encodedRenderingContext = enrichedRenderingContext ? encodeRenderingContext(enrichedRenderingContext) : null\n\n const url = new URL(tokenData.baseUrl)\n\n // Always safely decode the token before setting it since search params url encode the token and we do not want to double encode it.\n // in dev, since we're using 2 separate server for client and server, we have a redirect which prevents the double encoding.\n const decodedToken = safeDecodeURIComponent(tokenData.token)\n\n if (tokenData.paramLocation === 'search') {\n url.searchParams.set(tokenData.paramKey, decodedToken)\n } else if (tokenData.paramLocation === 'hash') {\n url.hash = tokenData.paramKey + '=' + encodeURIComponent(decodedToken)\n }\n\n url.searchParams.set('sdkVersion', sdkVersion)\n\n if (encodedRenderingContext) {\n url.searchParams.set('renderingContext', encodedRenderingContext)\n }\n\n if (theme) {\n url.searchParams.set('theme', theme)\n }\n\n const urlString = url.toString()\n return urlString\n } catch (error) {\n // communicate a general error about the token being invalid to the parent component, no matter which internal error we encountered during token parsing.\n onError?.(new InvalidTokenError())\n return undefined\n }\n}\n\nexport function tokenDataFromOneTimeToken(oneTimeToken: string): TokenData {\n const tokenObject = decodeOneTimeToken(oneTimeToken)\n const path = tokenObject.path\n if (!path || typeof path !== 'string') {\n throw new InvalidTokenError()\n }\n\n const tokenData: TokenData = {\n token: oneTimeToken,\n tokenType: TokenType.oneTime,\n baseUrl: path,\n paramKey: TokenParamKey.token,\n paramLocation: TokenParamLocation.search,\n }\n\n return tokenData\n}\n","import {\n IFrameOptions as BrokenIframeOptions,\n IFrameComponent,\n IFrameMessageData,\n IFrameResizedData,\n IFrameScrollData,\n iframeResizer,\n} from 'iframe-resizer'\nimport React, { IframeHTMLAttributes, forwardRef, useEffect, useImperativeHandle, useRef } from 'react'\n\n// the events were renamed but package maintainers didn't update the types.\ntype IFrameOptions = Omit<\n BrokenIframeOptions,\n 'closedCallback' | 'scrollCallback' | 'resizedCallback' | 'messageCallback' | 'initCallback'\n> & {\n onClosed?(iframeId: string): void\n onInit?(iframe: IFrameComponent): void\n onMessage?(data: IFrameMessageData): void\n onResized?(data: IFrameResizedData): void\n onScroll?(data: IFrameScrollData): boolean\n}\n\ntype IframeResizerProps = IFrameOptions & IframeHTMLAttributes<HTMLIFrameElement>\ntype EnrichedHtmlIframeElement = HTMLIFrameElement & { iFrameResizer: { removeListeners: () => void } }\n\nexport const IframeResizer = forwardRef((props: IframeResizerProps, ref: React.Ref<HTMLIFrameElement>) => {\n const title = props.title || 'iframe'\n const { iframeHTMLAttributes, resizerOptions } = splitProps(props)\n const iframeRef = useRef<HTMLIFrameElement>(null)\n\n useEffect(() => {\n // effects run after render, so the ref is guaranteed to be set (unless the component conditionally renders the iframe, which is not the case)\n const iframe = iframeRef.current as EnrichedHtmlIframeElement\n\n iframeResizer({ ...resizerOptions }, iframe)\n\n return () => iframe.iFrameResizer && iframe.iFrameResizer.removeListeners()\n })\n\n // make the ref provided as a prop point to the same place as the internal iframe ref.\n useImperativeHandle(ref, () => iframeRef.current as HTMLIFrameElement)\n\n return <iframe {...iframeHTMLAttributes} title={title} ref={iframeRef} />\n})\n\nIframeResizer.displayName = 'IframeResizer'\n\nconst resizerOptions = [\n 'autoResize',\n 'bodyBackground',\n 'bodyMargin',\n 'bodyPadding',\n 'checkOrigin',\n 'inPageLinks',\n 'heightCalculationMethod',\n 'interval',\n 'log',\n 'maxHeight',\n 'maxWidth',\n 'minHeight',\n 'minWidth',\n 'resizeFrom',\n 'scrolling',\n 'sizeHeight',\n 'sizeWidth',\n 'warningTimeout',\n 'tolerance',\n 'widthCalculationMethod',\n 'onClosed',\n 'onInit',\n 'onMessage',\n 'onResized',\n 'onScroll',\n]\n\nconst resizerOptionsSet = new Set(resizerOptions)\n\n/**\n * split props into the resizer library options and the native iframe attributes.\n * the code is contains many type assertions because typescript doesn't handle reduce well.\n */\nfunction splitProps(props: IframeResizerProps) {\n const split = (Object.keys(props) as Array<keyof IframeResizerProps>).reduce<{\n resizerOptions: IFrameOptions\n iframeHTMLAttributes: IframeHTMLAttributes<HTMLIFrameElement>\n }>(\n (acc, key) => {\n const value = props[key]\n if (resizerOptionsSet.has(key)) {\n if (value !== undefined) {\n acc.resizerOptions[key as keyof IFrameOptions] = props[key as keyof typeof props]\n }\n } else {\n acc.iframeHTMLAttributes[key as keyof IframeHTMLAttributes<HTMLIFrameElement>] =\n props[key as keyof typeof props]\n }\n return acc\n },\n { resizerOptions: {}, iframeHTMLAttributes: {} },\n )\n\n return split\n}\n","import React, { useMemo } from 'react'\nimport { useState } from 'react'\nimport { CSSProperties } from 'react'\n\nimport { CapitalOS } from './capital-os'\nimport { DevToolsButton } from './components/dev-tools-button'\nimport { EntryPoint } from './external-types'\nimport { CommonProps } from './types'\n\nconst styles: Record<string, CSSProperties> = {\n panel: {\n position: 'fixed',\n bottom: '20px',\n left: '20px',\n zIndex: 50,\n },\n}\n\n// #region Dev Tools\nexport type DevToolsProps = CommonProps\n\n/**\n * Renders the CapitalOS Dev Tools experience.\n * Allows for simulating transactions, etc.\n */\nexport function DevTools(props: DevToolsProps) {\n const entryPoint: EntryPoint = 'devTools'\n const renderingContext = useMemo(() => ({ entryPoint }), [entryPoint])\n\n const [isOpen, setIsOpen] = useState(false)\n\n return (\n <aside aria-label=\"CapitalOS dev tools\">\n {!isOpen && <DevToolsButton onClick={() => setIsOpen(!isOpen)} />}\n {isOpen && (\n <div style={styles['panel']}>\n <CapitalOS\n {...props}\n renderingContext={renderingContext}\n methods={{ devTools: { onClose: () => setIsOpen(false) } }}\n enableLogging={true}\n sizeWidth={true}\n loadingComponent={<DevToolsButton isLoading />}\n />\n </div>\n )}\n </aside>\n )\n}\n","import React, { useState } from 'react'\nimport { CSSProperties } from 'react'\n\nconst styles: Record<string, CSSProperties> = {\n bugButton: {\n position: 'fixed',\n left: '12px',\n bottom: '12px',\n margin: '12px',\n padding: '4px',\n display: 'inline-flex',\n alignItems: 'center',\n borderRadius: '9999px',\n border: '1px solid transparent',\n backgroundColor: '#2563eb',\n color: 'white',\n opacity: 0.4,\n boxShadow: '0 1px 3px 0 rgb(0 0 0 / 0.1)',\n cursor: 'pointer',\n zIndex: 50,\n transition: 'opacity 0.3s ease-in-out',\n },\n bugButtonHover: {\n backgroundColor: '#1d4ed8',\n opacity: 1,\n },\n bugButtonFocus: {\n outline: 'none',\n boxShadow: '0 0 0 2px white, 0 0 0 4px #3b82f6',\n },\n bugIcon: {\n width: '20px',\n height: '20px',\n },\n loadingButton: {\n cursor: 'default',\n opacity: 1,\n animation: 'pulse 1s cubic-bezier(0.4, 0, 0.6, 1) infinite',\n },\n}\n\nconst BugIcon = () => (\n <svg\n style={styles['bugIcon']}\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M12 12.75c1.148 0 2.278.08 3.383.237 1.037.146 1.866.966 1.866 2.013 0 3.728-2.35 6.75-5.25 6.75S6.75 18.728 6.75 15c0-1.046.83-1.867 1.866-2.013A24.204 24.204 0 0 1 12 12.75Zm0 0c2.883 0 5.647.508 8.207 1.44a23.91 23.91 0 0 1-1.152 6.06M12 12.75c-2.883 0-5.647.508-8.208 1.44.125 2.104.52 4.136 1.153 6.06M12 12.75a2.25 2.25 0 0 0 2.248-2.354M12 12.75a2.25 2.25 0 0 1-2.248-2.354M12 8.25c.995 0 1.971-.08 2.922-.236.403-.066.74-.358.795-.762a3.778 3.778 0 0 0-.399-2.25M12 8.25c-.995 0-1.97-.08-2.922-.236-.402-.066-.74-.358-.795-.762a3.734 3.734 0 0 1 .4-2.253M12 8.25a2.25 2.25 0 0 0-2.248 2.146M12 8.25a2.25 2.25 0 0 1 2.248 2.146M8.683 5a6.032 6.032 0 0 1-1.155-1.002c.07-.63.27-1.222.574-1.747m.581 2.749A3.75 3.75 0 0 1 15.318 5m0 0c.427-.283.815-.62 1.155-.999a4.471 4.471 0 0 0-.575-1.752M4.921 6a24.048 24.048 0 0 0-.392 3.314c1.668.546 3.416.914 5.223 1.082M19.08 6c.205 1.08.337 2.187.392 3.314a23.882 23.882 0 0 1-5.223 1.082\"\n />\n </svg>\n)\n\ninterface DevToolsButtonProps {\n onClick?: () => void\n isLoading?: boolean\n}\n\nexport function DevToolsButton({ onClick, isLoading = false }: DevToolsButtonProps) {\n const [isHovered, setIsHovered] = useState(false)\n const [isFocused, setIsFocused] = useState(false)\n\n const buttonStyle = {\n ...styles['bugButton'],\n ...(isLoading && styles['loadingButton']),\n ...(!isLoading && isHovered && styles['bugButtonHover']),\n ...(!isLoading && isFocused && styles['bugButtonFocus']),\n }\n\n if (isLoading) {\n return (\n <div style={buttonStyle}>\n <style>\n {`\n @keyframes pulse {\n 0%, 100% {\n opacity: 1;\n }\n 50% {\n opacity: 0.4;\n }\n }\n `}\n </style>\n <BugIcon />\n </div>\n )\n }\n\n return (\n <button\n id=\"dev-tools-button\"\n onClick={onClick}\n type=\"button\"\n style={buttonStyle}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n onFocus={() => setIsFocused(true)}\n onBlur={() => setIsFocused(false)}\n >\n <BugIcon />\n </button>\n )\n}\n"],"mappings":"+yBAEA,OAAOA,GAAS,WAAAC,MAAe,QCF/B,OAAOC,GAAS,aAAAC,GAAW,WAAAC,GAAS,UAAAC,GAAQ,YAAAC,GAAU,eAAAC,OAAmB,QCEzE,OAAOC,GAAS,iBAAAC,GAAe,cAAAC,GAAY,YAAAC,EAAU,WAAAC,GAAS,eAAAC,EAAa,aAAAC,OAAiB,QCF5F,OAAOC,IAAS,WAAAC,GAAS,UAAAC,OAAc,QCGhC,IAAMC,EAAN,cAA6B,KAAM,CAExC,YAAY,CAAE,QAAAC,EAAS,KAAAC,CAAK,EAAyC,CACnE,MAAMD,CAAO,EACb,KAAK,KAAO,iBACZ,KAAK,KAAOC,CACd,CACF,EAEaC,EAAY,CACvB,aAAc,eACd,uBAAwB,yBACxB,wBAAyB,0BACzB,eAAgB,gBAClB,EAOaC,EAAN,cAAgCJ,CAAe,CACpD,YAAYC,EAAkB,CAC5B,MAAM,CAAE,QAAS,iBAAiBA,GAAA,KAAAA,EAAW,EAAE,GAAI,KAAME,EAAU,YAAa,CAAC,EACjF,KAAK,KAAO,4BACd,CACF,EC7BA,OAAS,kBAAAE,OAAsB,SAC/B,OAAS,aAAAC,GAAW,WAAAC,GAAS,UAAAC,MAAc,QCCzC,IAAAC,EAAW,aCYN,SAASC,GAA0BC,EAAkC,CAC1E,IAAMC,EAAuB,KAAK,UAAUD,CAAgB,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MM,EAAyB,aACzBC,EAAmBC,EACvB,KAAO,CAAE,WAAAF,EAAY,qBAAAsB,EAAsB,oBAAAC,CAAoB,GAC/D,CAACvB,EAAYsB,EAAsBC,CAAmB,CACxD,EAEA,OAAOpB,EAAA,cAACC,EAAAC,EAAAC,EAAA,GAAcR,GAAd,CAA2B,iBAAkBG,EAAkB,QAAS,CAAE,WAAY,CAAE,OAAAL,CAAO,CAAE,GAAG,CAC9G,CAcO,SAAS4B,GAAY/B,EAA8C,CAA9C,IAAAC,EAAAD,EAAE,QAAAG,CArR9B,EAqR4BF,EAAaI,EAAAC,EAAbL,EAAa,CAAX,WAC5B,IAAMM,EAAyB,cACzBC,EAAmBC,EAAQ,KAAO,CAAE,WAAAF,CAAW,GAAI,CAACA,CAAU,CAAC,EAErE,OAAOG,EAAA,cAACC,EAAAC,EAAAC,EAAA,GAAcR,GAAd,CAA2B,iBAAkBG,EAAkB,QAAS,CAAE,YAAa,CAAE,OAAAL,CAAO,CAAE,GAAG,CAC/G","names":["React","useMemo","React","useEffect","useMemo","useRef","useState","useCallback","React","createContext","useContext","useState","useMemo","useCallback","useEffect","React","useMemo","useRef","CapitalOSError","message","code","ErrorCode","InvalidTokenError","connectToChild","useEffect","useMemo","useRef","version","encodeRenderingContext","renderingContext","renderingContextJson","renderingContextBase64","decodeOneTimeToken","token","urlDecodedToken","base64DecodedToken","error","InvalidTokenError","safeDecodeURIComponent","str","e","buildIframeUrl","tokenData","theme","onError","enrichedRenderingContext","__spreadProps","__spreadValues","encodedRenderingContext","url","decodedToken","version","tokenDataFromOneTimeToken","oneTimeToken","path","IFRAME_CONNECTION_TIMEOUT_MILLISECONDS","useIframeConnection","iframeRef","token","onError","methods","useEffect","connection","connectToChild","error","useIframeUrl","tokenData","renderingContext","theme","onErrorRef","useRef","renderingContextRef","useMemo","buildIframeUrl","iframeResizer","React","forwardRef","useEffect","useImperativeHandle","useRef","IframeResizer","forwardRef","props","ref","title","iframeHTMLAttributes","resizerOptions","splitProps","iframeRef","useRef","useEffect","iframe","iframeResizer","__spreadValues","useImperativeHandle","React","__spreadProps","resizerOptionsSet","acc","key","value","TokenExchangeIframe","props","oneTimeToken","enableLogging","onExchangeComplete","onExchangeError","iframeRef","useRef","tokenData","useMemo","tokenDataFromOneTimeToken","url","useIframeUrl","useIframeConnection","error","CapitalOSError","React","IframeResizer","CapitalOsAuthenticationContext","createContext","CapitalOsAuthenticationProvider","getToken","enableLogging","children","oneTimeToken","setOneTimeToken","useState","baseUrl","setBaseUrl","longLivedToken","setLongLivedToken","isLoading","setIsLoading","error","setError","refreshOneTimeToken","useCallback","__async","newToken","tokenObject","decodeOneTimeToken","url","invalidateToken","useEffect","onExchangeComplete","jwtToken","contextValue","useMemo","CapitalOSError","ErrorCode","React","TokenExchangeIframe","useCapitalOsAuthContext","useContext","CapitalOS","props","tokenProp","className","enableLogging","onError","LoadingComponent","renderingContext","methods","theme","sizeWidth","contextTokenData","error","invalidateToken","useCapitalOsAuthContext","isLoaded","setIsLoaded","useState","iframeRef","useRef","useErrorHandling","tokenData","useMemo","tokenDataFromOneTimeToken","handleTokenExpired","useCallback","CapitalOSError","ErrorCode","useEffect","url","useIframeUrl","useIframeConnection","__spreadValues","err","React","shouldAddPaddingBottom","IframeResizer","data","newHeight","errorFired","React","useMemo","useState","React","useState","styles","BugIcon","React","DevToolsButton","onClick","isLoading","isHovered","setIsHovered","useState","isFocused","setIsFocused","buttonStyle","__spreadValues","styles","DevTools","props","entryPoint","renderingContext","useMemo","isOpen","setIsOpen","useState","React","DevToolsButton","CapitalOS","__spreadProps","__spreadValues","CardsApp","props","entryPoint","renderingContext","useMemo","React","CapitalOS","__spreadProps","__spreadValues","App","IssueCard","_a","_b","cardholder","onDone","onCancel","restOfProps","__objRest","entryPoint","renderingContext","useMemo","React","CapitalOS","__spreadProps","__spreadValues","DisputeTransaction","transactionId","BillPayApp","props","CardDetails","onCardCanceled","AccountDetails","AccountActions","InsightsDashboard","InsightsWidget","widget","hideTitle","height","width","Onboarding","onboardingEntryPoint","onboardingExitPoint","MakePayment"]}
1
+ {"version":3,"sources":["../../src/index.tsx","../../src/capital-os.tsx","../../src/context/capital-os-authentication-context.tsx","../../src/common/token-exchange-iframe.tsx","../../src/error.ts","../../src/iframe-connection-hooks.ts","../../package.json","../../src/utils.ts","../../src/iframe-resizer.tsx","../../src/utils/logger.ts","../../src/context/actions-iframe-context.tsx","../../src/components/mfa.tsx","../../src/components/modal.tsx","../../src/hooks/use-mfa-state.ts","../../src/dev-tools.tsx","../../src/components/dev-tools-button.tsx"],"sourcesContent":["'use client'\n\nimport React, { useMemo, useContext } from 'react'\n\nimport { CapitalOS } from './capital-os'\nimport { ActionsIframeContext } from './context/actions-iframe-context'\nimport { CapitalOsAuthenticationProvider } from './context/capital-os-authentication-context'\nimport { DevTools } from './dev-tools'\nimport { CapitalOSError, ErrorCode } from './error'\nimport type { EntryPoint, IssueCardDefaultValues } from './external-types'\nimport type { Account, CommonProps } from './types'\n\n// #region App\n/**\n * Renders the CapitalOS CardsApp.\n */\nexport function CardsApp(props: CommonProps) {\n const entryPoint: EntryPoint = 'cardsApp'\n const renderingContext = useMemo(() => ({ entryPoint }), [entryPoint])\n return <CapitalOS {...props} renderingContext={renderingContext} />\n}\n// #endregion\n\n// maintain backwards compatibility\n\n/** @deprecated Use {@link CardsApp} instead */\nconst App = CardsApp\n\nexport { App }\n\n// #region Issue Card\nexport type IssueCardProps = CommonProps & {\n /**\n * Default values to prefill the form with.\n *\n * Either provide a userId, in which case the default values will be taken from that user's profile, or provide the cardholder's details directly.\n */\n cardholder?: IssueCardDefaultValues\n\n /**\n * Callback to invoke when the card was created successfully.\n */\n onDone: () => void\n\n /**\n * Callback to invoke when the card creation was cancelled by the user.\n */\n onCancel: () => void\n}\n\n/**\n * Renders the CapitalOS Issue Card experience.\n */\nexport function IssueCard({ cardholder, onDone, onCancel, ...restOfProps }: IssueCardProps) {\n const entryPoint: EntryPoint = 'createCard'\n const renderingContext = useMemo(\n () => ({\n entryPoint,\n cardholder,\n }),\n [cardholder],\n )\n\n return (\n <CapitalOS {...restOfProps} renderingContext={renderingContext} methods={{ createCard: { onDone, onCancel } }} />\n )\n}\n// #endregion\n\n// #region Dispute Transaction\nexport type DisputeTransactionProps = CommonProps & {\n /**\n * The ID of the transaction to dispute.\n */\n transactionId: string\n\n /**\n * Callback to invoke when the dispute was successfully submitted.\n */\n onDone: () => void\n\n /**\n * Callback to invoke when the user cancels the dispute submission.\n */\n onCancel: () => void\n}\n\n/**\n * Renders the CapitalOS Dispute Transaction experience.\n */\nexport function DisputeTransaction({ transactionId, onDone, onCancel, ...restOfProps }: DisputeTransactionProps) {\n const entryPoint: EntryPoint = 'createDispute'\n const renderingContext = useMemo(() => ({ entryPoint, transactionId }), [transactionId])\n\n return (\n <CapitalOS {...restOfProps} renderingContext={renderingContext} methods={{ createDispute: { onDone, onCancel } }} />\n )\n}\n// #endregion\n\n// #region Bill Payment Dashboard\nexport type BillPayAppProps = CommonProps\n\n/**\n * Renders the CapitalOS Bill Payment Dashboard experience.\n */\nexport function BillPayApp(props: BillPayAppProps) {\n const entryPoint: EntryPoint = 'billPayApp'\n const renderingContext = useMemo(() => ({ entryPoint }), [entryPoint])\n\n return <CapitalOS {...props} renderingContext={renderingContext} />\n}\n// #endregion\n\n// #region Card Details\nexport type CardDetailsProps = CommonProps & {\n /**\n * The ID of the card to manage.\n */\n cardId: string\n cardOnly?: boolean | undefined\n hideAddress?: boolean | undefined\n onCardCanceled?: () => void\n}\n\n/**\n * Renders the CapitalOS Manage Card experience.\n */\nexport function CardDetails(props: CardDetailsProps) {\n const { onCardCanceled, ...restOfProps } = props\n const entryPoint: EntryPoint = 'cardDetails'\n const renderingContext = useMemo(\n () => ({ entryPoint, cardId: props.cardId, cardOnly: props.cardOnly, hideAddress: props.hideAddress }),\n [entryPoint, props.cardId, props.cardOnly],\n )\n\n return (\n <CapitalOS\n {...restOfProps}\n renderingContext={renderingContext}\n methods={{ cardDetails: { onCardCanceled: onCardCanceled ?? (() => {}) } }}\n />\n )\n}\n// #endregion\n\n// #region Account Details\nexport type AccountDetailsProps = CommonProps\n\n/**\n * Renders the CapitalOS Account Details experience.\n */\nexport function AccountDetails(props: AccountDetailsProps) {\n const entryPoint: EntryPoint = 'accountDetails'\n const renderingContext = useMemo(() => ({ entryPoint }), [entryPoint])\n\n return <CapitalOS {...props} renderingContext={renderingContext} />\n}\n// #endregion\n\n// #region Account Actions\nexport type AccountActionsProps = CommonProps\n\n/**\n * Renders the CapitalOS Account Actions experience.\n */\nexport function AccountActions(props: AccountActionsProps) {\n const entryPoint: EntryPoint = 'accountActions'\n const renderingContext = useMemo(() => ({ entryPoint }), [entryPoint])\n\n return <CapitalOS {...props} renderingContext={renderingContext} />\n}\n// #endregion\n\n// #region Insights Dashboard\nexport type InsightsDashboardProps = CommonProps\n\n/**\n * Renders the CapitalOS Insights Dashboard experience\n */\nexport function InsightsDashboard(props: InsightsDashboardProps) {\n const entryPoint: EntryPoint = 'insightsDashboard'\n const renderingContext = useMemo(() => ({ entryPoint }), [entryPoint])\n\n return <CapitalOS {...props} renderingContext={renderingContext} />\n}\n// #endregion\n\n// #region Insights Widget\nexport type InsightsWidgetProps = CommonProps & {\n /**\n * The specific widget to render.\n * naming convention:\n * 1. Over-time Widgets\n * over-time-{metric}-by-{dimension}-per-{time-granularity}\n * 2. Top/Ranking Widgets\n * top-{entities}-by-{metric}-{timeframe}\n * 3. Comparison Widgets\n * comparison-{metric}-{primary-timeframe}-vs-{secondary-timeframe}\n */\n widget:\n | 'over-time-spend-by-card-per-month'\n | 'over-time-spend-by-category-per-month'\n | 'top-cards-by-spend-this-month'\n | 'top-categories-by-spend-this-month'\n | 'top-transactions-by-amount-this-month'\n | 'comparison-spend-this-month-vs-last-month'\n /**\n * Whether to hide the title of the widget.\n */\n hideTitle?: boolean | undefined\n /**\n * The height of the widget.\n */\n height?: number | undefined\n /**\n * The width of the widget.\n */\n width?: number | undefined\n}\n\n/**\n * Renders a specific CapitalOS Insights Widget\n */\nexport function InsightsWidget(props: InsightsWidgetProps) {\n const entryPoint: EntryPoint = 'insightsWidget'\n const { widget, hideTitle, height, width } = props\n const renderingContext = useMemo(\n () => ({ entryPoint, widget, hideTitle, height, width }),\n [entryPoint, widget, hideTitle, height, width],\n )\n\n return <CapitalOS {...props} renderingContext={renderingContext} />\n}\n// #endregion\n\n// #region Onboarding\ntype AllowedExitPoints = {\n welcome: 'application' | 'activation'\n application: 'application' | 'activation'\n}\n\ntype OnboardingEntryPoint = keyof AllowedExitPoints\ntype OnboardingProps<T extends keyof AllowedExitPoints> = CommonProps & {\n entryPoint?: T\n exitPoint?: AllowedExitPoints[T]\n onDone: (account: Account) => void\n}\n\nexport function Onboarding<T extends OnboardingEntryPoint>({\n onDone,\n entryPoint: onboardingEntryPoint,\n exitPoint: onboardingExitPoint,\n ...restOfProps\n}: OnboardingProps<T>) {\n // This component uses 'entryPoint' in two distinct ways:\n // 1. As a prop to control the user's starting/ending stages of onboarding\n // 2. For internal rendering context to determine which client component to display\n const entryPoint: EntryPoint = 'onboarding'\n const renderingContext = useMemo(\n () => ({ entryPoint, onboardingEntryPoint, onboardingExitPoint }),\n [entryPoint, onboardingEntryPoint, onboardingExitPoint],\n )\n\n return <CapitalOS {...restOfProps} renderingContext={renderingContext} methods={{ onboarding: { onDone } }} />\n}\n// #endregion\n\n// #region Make a payment\nexport type MakePaymentProps = CommonProps & {\n /**\n * Callback to invoke when the payment was made successfully.\n */\n onDone: () => void\n}\n\n/**\n * Renders the CapitalOS Make a Payment experience.\n */\nexport function MakePayment({ onDone, ...restOfProps }: MakePaymentProps) {\n const entryPoint: EntryPoint = 'makePayment'\n const renderingContext = useMemo(() => ({ entryPoint }), [entryPoint])\n\n return <CapitalOS {...restOfProps} renderingContext={renderingContext} methods={{ makePayment: { onDone } }} />\n}\n// #endregion\n\n// #region Dev Tools\nexport { DevTools }\n// #endregion\n\n// #region Contact Support\nexport type ContactSupportProps = CommonProps & {\n onDone: () => void\n onCancel: () => void\n}\n\nexport function ContactSupport({ onDone, onCancel, ...restOfProps }: ContactSupportProps) {\n const entryPoint: EntryPoint = 'contactSupport'\n const renderingContext = useMemo(() => ({ entryPoint }), [entryPoint])\n\n return (\n <CapitalOS\n {...restOfProps}\n renderingContext={renderingContext}\n methods={{ contactSupport: { onDone, onCancel } }}\n />\n )\n}\n\n// #endregion\n\n// #region Statements\nexport type StatementsProps = CommonProps & {\n onDone: () => void\n}\n\nexport function Statements({ onDone, ...restOfProps }: StatementsProps) {\n const entryPoint: EntryPoint = 'statements'\n const renderingContext = useMemo(() => ({ entryPoint }), [entryPoint])\n\n return <CapitalOS {...restOfProps} renderingContext={renderingContext} methods={{ statements: { onDone } }} />\n}\n// #endregion\n\n// #region Legal Documents\nexport type LegalDocumentsProps = CommonProps & {\n onDone: () => void\n}\n\nexport function LegalDocuments({ onDone, ...restOfProps }: LegalDocumentsProps) {\n const entryPoint: EntryPoint = 'legalDocuments'\n const renderingContext = useMemo(() => ({ entryPoint }), [entryPoint])\n\n return <CapitalOS {...restOfProps} renderingContext={renderingContext} methods={{ legalDocuments: { onDone } }} />\n}\n// #endregion\n\n// #region Replace Card\nexport type ReplaceCardProps = CommonProps & {\n cardId: string\n onDone: () => void\n onClose: () => void\n}\n\nexport function ReplaceCard({ cardId, onDone, onClose, ...restOfProps }: ReplaceCardProps) {\n const entryPoint: EntryPoint = 'replaceCard'\n const renderingContext = useMemo(() => ({ entryPoint, cardId }), [cardId])\n\n return (\n <CapitalOS {...restOfProps} renderingContext={renderingContext} methods={{ replaceCard: { onDone, onClose } }} />\n )\n}\n// #endregion\n\n// #region Terminate Card\nexport type TerminateCardProps = CommonProps & {\n cardId: string\n onDone: () => void\n onClose: () => void\n}\n\nexport function TerminateCard({ cardId, onDone, onClose, ...restOfProps }: TerminateCardProps) {\n const entryPoint: EntryPoint = 'terminateCard'\n const renderingContext = useMemo(() => ({ entryPoint, cardId }), [cardId])\n\n return (\n <CapitalOS {...restOfProps} renderingContext={renderingContext} methods={{ terminateCard: { onDone, onClose } }} />\n )\n}\n// #endregion\n\n// #region Authentication provider\nexport { CapitalOsAuthenticationProvider }\n// #endregion\n\n// #region Actions\n/**\n * Hook to access the actions iframe functions.\n *\n * @returns An object containing the actions functions and loading state\n * @throws {CapitalOSError} If the hook is used outside of a CapitalOS component\n *\n * @example\n * ```tsx\n * const { actions, isLoading } = useActions()\n *\n * if (isLoading) {\n * return <LoadingSpinner />\n * }\n *\n * // Use the actions\n * await actions.freezeCard()\n * ```\n */\nexport function useActions() {\n const context = useContext(ActionsIframeContext)\n\n if (!context) {\n throw new CapitalOSError({\n message: 'useActions must be used within a CapitalOsAuthenticationProvider',\n code: ErrorCode.internal_error,\n })\n }\n\n const { childFunctions, isLoading } = context\n\n return {\n actions: childFunctions,\n isLoading,\n }\n}\n// #endregion\n","import React from 'react'\n\nimport { useEnableLogging } from './context/capital-os-authentication-context'\nimport { ParentFunctions, useIframe } from './iframe-connection-hooks'\nimport { IframeResizer } from './iframe-resizer'\nimport { CommonProps, CapitalOsRenderingContext } from './types'\n\ntype CapitalOsProps<T extends CapitalOsRenderingContext> = CommonProps & {\n renderingContext: T\n methods?: Partial<ParentFunctions>\n sizeWidth?: boolean\n}\n\n/**\n * The internal component that handles all the heavy lifting of connecting to the iframe and rendering the app.\n * all user facing components are basically a syntactic sugar on top of this.\n */\nexport function CapitalOS<T extends CapitalOsRenderingContext>(props: CapitalOsProps<T>) {\n const {\n token: tokenProp,\n className,\n enableLogging,\n onError,\n loadingComponent: LoadingComponent,\n renderingContext,\n methods,\n theme,\n sizeWidth,\n } = props\n const enableLoggingResolved = useEnableLogging(enableLogging)\n\n const { isLoaded, url, tokenData, iframeRef } = useIframe({\n oneTimeToken: tokenProp,\n enableLogging: enableLoggingResolved,\n onError,\n renderingContext,\n theme,\n methods,\n })\n\n if (!tokenData || !url) {\n return <>{LoadingComponent || null}</>\n }\n\n // insightsWidget does not need additional padding. also - it supports a height property that needs to be respected.\n const shouldAddPaddingBottom = renderingContext.entryPoint !== 'insightsWidget'\n\n return (\n <>\n {/* show loader as long as we're not loaded */}\n {!isLoaded && LoadingComponent}\n {/* hide the iframe as long as we're not loaded */}\n <IframeResizer\n src={url}\n allow=\"clipboard-write\"\n checkOrigin={false}\n style={{ width: '1px', height: '0px', minWidth: '100%' }}\n className={className}\n log={enableLoggingResolved}\n ref={iframeRef}\n hidden={!isLoaded}\n // Add a constant offset to the height of the iframe to account for css shadows.\n // This is useful for tooltips that are rendered with shadows below them that extend beyond the bottom of the tooltip.\n onResized={(data) => {\n if (!shouldAddPaddingBottom) {\n return\n }\n\n // typing is wrong here. this is a string.\n const newHeight = `${parseInt(data.height as unknown as string) + 12}px`\n data.iframe.style.height = newHeight\n }}\n sizeWidth={sizeWidth}\n />\n </>\n )\n}\n","'use client'\n\nimport React, { createContext, useContext, useState, useMemo, useCallback, useEffect } from 'react'\n\nimport { TokenExchangeIframe } from '../common/token-exchange-iframe'\nimport { CapitalOSError, ErrorCode } from '../error'\nimport { TokenData, TokenParamKey, TokenParamLocation, TokenType } from '../types'\nimport { decodeOneTimeToken } from '../utils'\nimport { logger } from '../utils/logger'\nimport { ActionsIframeProvider } from './actions-iframe-context'\n\ntype CapitalOsAuthenticationContextType = {\n tokenData?: TokenData | undefined\n isLoading: boolean\n error?: Error | undefined\n /**\n * Invalidates the current token..\n * This is used when the iframe signals that the token has expired.\n * The authentication flow will automatically refresh the token after invalidation.\n */\n invalidateToken: () => void\n /**\n * Optional flag indicating whether to log events to the console.\n */\n enableLogging: boolean\n}\n\ntype ProviderProps = {\n getToken: () => Promise<string>\n enableLogging?: boolean | undefined\n children: React.ReactNode\n}\n\nconst CapitalOsAuthenticationContext = createContext<CapitalOsAuthenticationContextType>({\n isLoading: false,\n invalidateToken: () => {},\n enableLogging: false,\n})\n\nexport const CapitalOsAuthenticationProvider: React.FC<ProviderProps> = ({ getToken, enableLogging, children }) => {\n const [oneTimeToken, setOneTimeToken] = useState<string | undefined>(undefined)\n const [baseUrl, setBaseUrl] = useState<string | undefined>(undefined)\n const [longLivedToken, setLongLivedToken] = useState<string | undefined>(undefined)\n const [isLoading, setIsLoading] = useState(false)\n const [error, setError] = useState<Error | undefined>(undefined)\n\n const refreshOneTimeToken = useCallback(async () => {\n setIsLoading(true)\n try {\n const newToken = await getToken()\n setOneTimeToken(newToken)\n setError(undefined)\n const tokenObject = decodeOneTimeToken(newToken)\n const url = new URL(tokenObject.path)\n // we don't need the /login part of the path since long lived tokens don't go through the login flow.\n url.pathname = ''\n setBaseUrl(url.toString())\n } catch (error) {\n setError(error as Error)\n } finally {\n setIsLoading(false)\n }\n }, [getToken])\n\n // Add invalidateToken method\n const invalidateToken = useCallback(() => {\n setLongLivedToken(undefined)\n }, [])\n\n // On mount, if no long-lived token is available, refresh to get a one-time token.\n useEffect(() => {\n if (!longLivedToken) {\n refreshOneTimeToken()\n }\n }, [longLivedToken, refreshOneTimeToken])\n\n const onExchangeComplete = useCallback((jwtToken: string) => {\n setLongLivedToken(jwtToken)\n setOneTimeToken(undefined)\n setError(undefined)\n }, [])\n\n const contextValue: CapitalOsAuthenticationContextType = useMemo(() => {\n if (longLivedToken && !baseUrl) {\n throw new CapitalOSError({\n message: 'baseUrl is required for long lived tokens',\n code: ErrorCode.unauthorized,\n })\n }\n const tokenData: TokenData | undefined = longLivedToken\n ? ({\n token: longLivedToken,\n tokenType: TokenType.longLived,\n baseUrl: baseUrl!,\n paramKey: TokenParamKey.accessToken,\n paramLocation: TokenParamLocation.hash,\n } as const)\n : undefined\n\n return {\n tokenData,\n isLoading,\n error,\n invalidateToken,\n enableLogging: enableLogging ?? false,\n }\n }, [longLivedToken, isLoading, error, invalidateToken, baseUrl, enableLogging])\n\n return (\n <>\n <CapitalOsAuthenticationContext.Provider value={contextValue}>\n <ActionsIframeProvider>{children}</ActionsIframeProvider>\n </CapitalOsAuthenticationContext.Provider>\n {oneTimeToken && !longLivedToken && (\n <TokenExchangeIframe\n oneTimeToken={oneTimeToken}\n onExchangeComplete={onExchangeComplete}\n enableLogging={enableLogging}\n onExchangeError={setError}\n />\n )}\n </>\n )\n}\n\nexport const useCapitalOsAuthContext = () => useContext(CapitalOsAuthenticationContext)\n\n/**\n * Hook to resolve logging preference, with direct prop taking precedence over context.\n * @param enableLoggingProp Direct prop for enableLogging.\n * @returns Effective logging flag.\n */\nexport function useEnableLogging(enableLoggingProp?: boolean): boolean {\n const { enableLogging: contextEnableLogging } = useCapitalOsAuthContext()\n return enableLoggingProp !== undefined ? enableLoggingProp : contextEnableLogging\n}\n\n/**\n * Hook that provides stable logging functions (log, warn, error), scoped to the resolved enableLogging flag.\n * @param enableLoggingProp Optional direct prop to override logging.\n */\nexport function useLogger(enableLoggingProp?: boolean) {\n const enableLogging = useEnableLogging(enableLoggingProp)\n const log = useCallback(\n (message: string) => {\n logger.log(message, { enableLogging })\n },\n [enableLogging],\n )\n const warn = useCallback(\n (message: string) => {\n logger.warn(message, { enableLogging })\n },\n [enableLogging],\n )\n const error = useCallback(\n (message: string) => {\n logger.error(message, { enableLogging })\n },\n [enableLogging],\n )\n return useMemo(() => ({ log, warn, error }), [log, warn, error])\n}\n","import React, { useMemo, useRef } from 'react'\n\nimport { useEnableLogging } from '../context/capital-os-authentication-context'\nimport { CapitalOSError } from '../error'\nimport { useIframeConnection, useIframeUrl } from '../iframe-connection-hooks'\nimport { IframeResizer } from '../iframe-resizer'\nimport { tokenDataFromOneTimeToken } from '../utils'\n\nexport interface TokenExchangeIframeProps {\n oneTimeToken: string\n enableLogging?: boolean | undefined\n onExchangeComplete: (jwtToken: string) => void\n onExchangeError?: (error: Error) => void\n}\n\n/**\n * The component is hidden from the user and is only used to exchange a one-time token for a JWT in the authentication context.\n *\n * The token exchange process works as follows:\n * 1. Component renders a hidden iframe with the one-time token in the URL\n * 2. The iframe loads with the long-lived token as part of its url redirect response and establishes a secure connection with the parent window\n * 3. The iframe passes the long-lived token to the parent via postMessage\n * 4. onExchangeComplete callback is triggered with the new JWT\n *\n * If any errors occur during this process, they are passed to onExchangeError.\n */\nexport function TokenExchangeIframe(props: TokenExchangeIframeProps) {\n const { oneTimeToken, enableLogging, onExchangeComplete, onExchangeError } = props\n const enableLoggingResolved = useEnableLogging(enableLogging)\n\n const iframeRef = useRef<HTMLIFrameElement>(null)\n\n const tokenData = useMemo(() => tokenDataFromOneTimeToken(oneTimeToken), [oneTimeToken])\n\n const renderingContext = {\n entryPoint: 'tokenExchange',\n } as const\n\n const url = useIframeUrl({\n tokenData,\n onError: onExchangeError,\n renderingContext,\n })\n\n useIframeConnection({\n iframeRef,\n token: oneTimeToken,\n onError: onExchangeError,\n methods: {\n onLoad: () => {},\n onError: (error) => {\n onExchangeError?.(new CapitalOSError(error))\n },\n tokenExchange: {\n onLongLivedToken: onExchangeComplete,\n },\n },\n })\n\n // Render the hidden iframe.\n return (\n <IframeResizer\n src={url}\n checkOrigin={false}\n style={{ display: 'none' }} // Hidden from view\n log={enableLoggingResolved}\n ref={iframeRef}\n />\n )\n}\n","/**\n * Base class for all SDK errors\n */\nexport class CapitalOSError extends Error {\n code: ErrorCode\n constructor({ message, code }: { message: string; code: ErrorCode }) {\n super(message)\n this.name = 'CapitalOSError'\n this.code = code\n }\n}\n\nexport const ErrorCode = {\n unauthorized: 'unauthorized',\n invalid_account_status: 'invalid_account_status',\n unsupported_entry_point: 'unsupported_entry_point',\n internal_error: 'internal_error',\n} as const\n\nexport type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode]\n\n/**\n * Represents an error that occurs when an invalid token is encountered.\n */\nexport class InvalidTokenError extends CapitalOSError {\n constructor(message?: string) {\n super({ message: `Invalid token ${message ?? ''}`, code: ErrorCode.unauthorized })\n this.name = 'CapitalOSInvalidTokenError'\n }\n}\n\nexport class TokenRefreshError extends CapitalOSError {\n constructor(originalError?: Error) {\n super({\n message: `Failed to refresh token: ${originalError?.message}`,\n code: ErrorCode.unauthorized,\n })\n this.name = 'CapitalOSTokenRefreshError'\n }\n}\n","import { connectToChild, Connection } from 'penpal'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport { useCapitalOsAuthContext, useLogger } from './context/capital-os-authentication-context'\nimport { CapitalOSError, ErrorCode } from './error'\nimport {\n Account,\n Card,\n ThemeColorScheme,\n CapitalOsRenderingContext,\n TokenData,\n MfaResult,\n MfaRequestContext,\n} from './types'\nimport { buildIframeUrl, tokenDataFromOneTimeToken } from './utils'\n\nconst IFRAME_CONNECTION_TIMEOUT_MILLISECONDS = 10_000\n\n/**\n * An error type providing a reason code and message.\n * Penpal only passes plain objects, so this does not inherit from Error.\n */\nexport type RawErrorDetails = {\n code: ErrorCode\n message: string\n}\n\nexport type ParentFunctions = {\n onLoad: () => void\n onError: (error: RawErrorDetails) => void\n /**\n * Called when the iframe detects that the JWT token has expired.\n * This triggers the token refresh flow, which will obtain a new token\n * and reload the iframe with the fresh token.\n */\n onTokenExpired?: () => void\n cardDetails?: {\n onCardCanceled?: () => void\n }\n contactSupport?: {\n onDone?: () => void\n onCancel?: () => void\n }\n createCard?: {\n onDone?: () => void\n onCancel?: () => void\n }\n createDispute?: {\n onDone?: () => void\n onCancel?: () => void\n }\n devTools?: {\n onClose?: () => void\n }\n legalDocuments?: {\n onDone?: () => void\n }\n makePayment?: {\n onDone?: () => void\n }\n mfa?: {\n onDone?: () => void\n onCancel?: () => void\n }\n onboarding?: {\n onDone?: (account: Account) => void\n }\n replaceCard?: {\n onDone?: () => void\n onClose?: () => void\n }\n 'system-messages'?: {\n requestMfa?: (context: MfaRequestContext) => Promise<MfaResult>\n }\n statements?: {\n onDone?: () => void\n }\n terminateCard?: {\n onDone?: () => void\n onClose?: () => void\n }\n tokenExchange?: {\n onLongLivedToken?: (jwtToken: string) => void\n }\n}\n\n// Client-side ActionResult type (uses string errors for Penpal serialization)\nexport type ClientActionResult<T> =\n | { success: true; canceled: false; data: T }\n | { success: false; canceled: true }\n | { success: false; canceled: false; error: string }\n\nexport type ChildFunctions = {\n freezeCard: (cardId: string) => Promise<ClientActionResult<Card>>\n unfreezeCard: (cardId: string) => Promise<ClientActionResult<Card>>\n}\n\n/**\n * connects to child iframe and returns whether the iframe is loaded or not.\n * token was added to the list of dependencies to make sure that the connection is re-established when the token changes.\n */\nexport function useIframeConnection({\n iframeRef,\n token,\n onError,\n methods,\n}: {\n iframeRef: React.RefObject<HTMLIFrameElement>\n token: string | undefined\n onError: ((error: Error) => void) | undefined | null\n methods: ParentFunctions\n}) {\n // connect to child iframe\n const [connection, setConnection] = useState<Connection<ChildFunctions> | null>(null)\n\n useEffect(() => {\n if (!iframeRef.current) {\n return\n }\n\n const newConnection = connectToChild<ChildFunctions>({\n iframe: iframeRef.current,\n childOrigin: '*',\n debug: true,\n timeout: IFRAME_CONNECTION_TIMEOUT_MILLISECONDS,\n methods,\n })\n\n newConnection.promise\n .then(() => {\n setConnection(newConnection)\n })\n .catch((error) => {\n onError?.(error)\n setConnection(null)\n })\n\n return () => {\n newConnection.destroy()\n setConnection(null)\n }\n }, [token, iframeRef])\n\n return connection\n}\n\n/**\n * returns a memoized url of the iframe or undefined if the token is not available yet.\n */\nexport function useIframeUrl({\n tokenData,\n renderingContext,\n theme,\n onError,\n}: {\n tokenData: TokenData | undefined\n renderingContext: CapitalOsRenderingContext\n theme?: ThemeColorScheme | undefined\n onError?: ((error: Error) => void) | undefined\n}) {\n // We assume that onError and renderingContext do not change over the lifetime of the component.\n // We put it in a ref to avoid causing unnecessary re-renders.\n const onErrorRef = useRef(onError)\n const renderingContextRef = useRef(renderingContext)\n\n return useMemo(() => {\n if (!tokenData) {\n return undefined\n }\n return buildIframeUrl({\n tokenData,\n renderingContext: renderingContextRef.current,\n theme,\n onError: onErrorRef.current,\n })\n // wrapped rendering context in a ref since we do not want to reload the iframe unless the token changes.\n }, [tokenData, theme, onErrorRef, renderingContextRef])\n}\n\n/**\n * A React hook that manages the iframe connection lifecycle, including:\n * - Establishing and maintaining the iframe connection\n * - Handling token expiration and refresh flows\n * - Managing loading states\n * - Coordinating between one-time tokens and context-based authentication\n * - Providing error handling and logging capabilities\n */\nexport function useIframe(props: {\n renderingContext: CapitalOsRenderingContext\n oneTimeToken?: string | undefined\n enableLogging?: boolean | undefined\n onError?: ((error: Error) => void) | undefined\n theme?: ThemeColorScheme | undefined\n methods?: Partial<Omit<ParentFunctions, 'onLoad' | 'onError' | 'onTokenExpired'>> | undefined\n}) {\n const { oneTimeToken, enableLogging: enableLoggingProp, onError, renderingContext, theme, methods } = props\n const { tokenData: contextTokenData, error, invalidateToken } = useCapitalOsAuthContext()\n const { log, warn } = useLogger(enableLoggingProp)\n // represents the state of whether all required react queries returned and the page should be visible\n const [isLoaded, setIsLoaded] = useState(false)\n const iframeRef = useRef<HTMLIFrameElement>(null)\n useErrorHandling(error, onError)\n\n const tokenData: TokenData | undefined = useMemo(\n () => (oneTimeToken ? tokenDataFromOneTimeToken(oneTimeToken) : contextTokenData),\n [oneTimeToken, contextTokenData],\n )\n\n // Handle token expiration by invalidating the token\n // The context's useEffect will automatically handle the refresh\n const handleTokenExpired = useCallback(() => {\n log('Token expired, invalidating...')\n\n // If we're using tokenProp, we can't refresh automatically\n if (oneTimeToken) {\n onError?.(\n new CapitalOSError({\n message: 'Token expired. Cannot automatically refresh when using token prop.',\n code: ErrorCode.unauthorized,\n }),\n )\n return\n }\n\n // Use the invalidateToken function from the context\n // This will clear the token and the authentication context's useEffect will handle the refresh\n invalidateToken()\n\n // The iframe will be reloaded automatically when tokenData changes\n setIsLoaded(false)\n }, [oneTimeToken, invalidateToken, log, onError])\n\n useEffect(() => {\n if (oneTimeToken && contextTokenData) {\n warn('token was provided both from provider and from the token prop. the prop will take precedence')\n }\n }, [oneTimeToken, contextTokenData, warn])\n\n const url = useIframeUrl({ tokenData, renderingContext, theme, onError })\n\n const connection = useIframeConnection({\n iframeRef,\n token: tokenData?.token,\n onError: (error) => {\n onError?.(error)\n // when connection fails it's probably a handshake timeout with the iframe. we will stop showing the loader\n // since the fact we failed communication doesn't necessarily mean the iframe didn't load\n setIsLoaded(true)\n },\n methods: {\n onLoad: () => {\n setIsLoaded(true)\n },\n onError: (error) => {\n const err = new CapitalOSError(error)\n onError?.(err)\n },\n onTokenExpired: handleTokenExpired,\n ...methods,\n },\n })\n\n return { isLoaded, url, tokenData, iframeRef, connection }\n}\n\n/**\n * Makes sure component only fires the error event once.\n * @param error - The error to handle.\n * @param onError - The function to call when the error occurs.\n */\nfunction useErrorHandling(error: Error | null | undefined, onError?: (error: Error) => void) {\n const errorFired = useRef(false)\n\n useEffect(() => {\n if (error && !errorFired.current) {\n onError?.(error)\n errorFired.current = true\n }\n }, [error, onError])\n}\n","{\n \"name\": \"@capitalos/react\",\n \"version\": \"1.2.1-rc.1\",\n \"description\": \"integrate CapitalOS into your react app\",\n \"main\": \"dist/index.js\",\n \"module\": \"dist/esm/index.js\",\n \"types\": \"dist/_tsup-dts-rollup.d.ts\",\n \"scripts\": {\n \"build\": \" pnpm lint && tsup src/index.tsx --experimental-dts --minify --format esm,cjs --clean --no-splitting --sourcemap --legacy-output --out-dir dist\",\n \"dev\": \"pnpm build --watch\",\n \"prepublishOnly\": \"pnpm build\",\n \"lint\": \"eslint . --ext .ts,.tsx --fix\",\n \"lint-ci\": \"eslint . --ext .ts,.tsx\"\n },\n \"keywords\": [\n \"capitalos\",\n \"react\"\n ],\n \"homepage\": \"https://docs.capitalos.com/docs/using-react-client-library\",\n \"author\": \"CapitalOS\",\n \"license\": \"MIT\",\n \"files\": [\n \"dist\",\n \"package.json\"\n ],\n \"devDependencies\": {\n \"@changesets/cli\": \"^2.27.12\",\n \"@microsoft/api-extractor\": \"^7.39.5\",\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/iframe-resizer\": \"^3.5.13\",\n \"@types/react\": \"18.0.20\",\n \"@typescript-eslint/eslint-plugin\": \"^7.2.0\",\n \"@typescript-eslint/parser\": \"^7.2.0\",\n \"eslint\": \"^8.57.0\",\n \"eslint-config-prettier\": \"^9.1.0\",\n \"eslint-plugin-prettier\": \"^5.1.3\",\n \"eslint-plugin-react\": \"^7.34.0\",\n \"prettier\": \"^3.2.5\",\n \"react\": \"16.8.0\",\n \"tsup\": \"^8.1.0\",\n \"typescript\": \"^5.6.2\"\n },\n \"dependencies\": {\n \"iframe-resizer\": \"^4.3.9\",\n \"penpal\": \"^6.2.2\"\n },\n \"peerDependencies\": {\n \"react\": \">=16.8.0\"\n }\n}\n","import { version as sdkVersion } from '../package.json'\nimport { InvalidTokenError } from './error'\nimport {\n ThemeColorScheme,\n CapitalOsRenderingContext,\n TokenData,\n TokenType,\n TokenParamKey,\n TokenParamLocation,\n} from './types'\n\n/**\n * Encodes the rendering context as base64 and then URI encodes it.\n */\nexport function encodeRenderingContext<T>(renderingContext: NonNullable<T>) {\n const renderingContextJson = JSON.stringify(renderingContext)\n const renderingContextBase64 = btoa(renderingContextJson)\n const renderingContextEncoded = encodeURIComponent(renderingContextBase64)\n\n return renderingContextEncoded\n}\n\nexport function decodeOneTimeToken(token: string) {\n try {\n const urlDecodedToken = decodeURIComponent(token)\n const base64DecodedToken = atob(urlDecodedToken)\n return JSON.parse(base64DecodedToken)\n } catch (error) {\n throw new InvalidTokenError()\n }\n}\n\n/**\n * Safely decodes a URL component, handling potential errors\n */\nexport function safeDecodeURIComponent(str: string): string {\n try {\n return decodeURIComponent(str)\n } catch (e) {\n // If decoding fails, it might not have been encoded, so return original\n return str\n }\n}\n\n/**\n * Builds the iframe url from token data, rendering context, and theme.\n */\nexport function buildIframeUrl({\n tokenData,\n renderingContext,\n theme,\n onError,\n}: {\n tokenData: TokenData\n renderingContext: CapitalOsRenderingContext\n theme?: ThemeColorScheme | undefined\n onError?: ((error: Error) => void) | undefined\n}) {\n try {\n const enrichedRenderingContext = renderingContext\n ? {\n ...renderingContext,\n referer: window.location.href,\n }\n : null\n\n const encodedRenderingContext = enrichedRenderingContext ? encodeRenderingContext(enrichedRenderingContext) : null\n\n const url = new URL(tokenData.baseUrl)\n\n // Always safely decode the token before setting it since search params url encode the token and we do not want to double encode it.\n // in dev, since we're using 2 separate server for client and server, we have a redirect which prevents the double encoding.\n const decodedToken = safeDecodeURIComponent(tokenData.token)\n\n if (tokenData.paramLocation === 'search') {\n url.searchParams.set(tokenData.paramKey, decodedToken)\n } else if (tokenData.paramLocation === 'hash') {\n url.hash = tokenData.paramKey + '=' + encodeURIComponent(decodedToken)\n }\n\n url.searchParams.set('sdkVersion', sdkVersion)\n\n if (encodedRenderingContext) {\n url.searchParams.set('renderingContext', encodedRenderingContext)\n }\n\n if (theme) {\n url.searchParams.set('theme', theme)\n }\n\n const urlString = url.toString()\n return urlString\n } catch (error) {\n // communicate a general error about the token being invalid to the parent component, no matter which internal error we encountered during token parsing.\n onError?.(new InvalidTokenError())\n return undefined\n }\n}\n\nexport function tokenDataFromOneTimeToken(oneTimeToken: string): TokenData {\n const tokenObject = decodeOneTimeToken(oneTimeToken)\n const path = tokenObject.path\n if (!path || typeof path !== 'string') {\n throw new InvalidTokenError()\n }\n\n const tokenData: TokenData = {\n token: oneTimeToken,\n tokenType: TokenType.oneTime,\n baseUrl: path,\n paramKey: TokenParamKey.token,\n paramLocation: TokenParamLocation.search,\n }\n\n return tokenData\n}\n","import {\n IFrameOptions as BrokenIframeOptions,\n IFrameComponent,\n IFrameMessageData,\n IFrameResizedData,\n IFrameScrollData,\n iframeResizer,\n} from 'iframe-resizer'\nimport React, { IframeHTMLAttributes, forwardRef, useEffect, useImperativeHandle, useRef } from 'react'\n\n// the events were renamed but package maintainers didn't update the types.\ntype IFrameOptions = Omit<\n BrokenIframeOptions,\n 'closedCallback' | 'scrollCallback' | 'resizedCallback' | 'messageCallback' | 'initCallback'\n> & {\n onClosed?(iframeId: string): void\n onInit?(iframe: IFrameComponent): void\n onMessage?(data: IFrameMessageData): void\n onResized?(data: IFrameResizedData): void\n onScroll?(data: IFrameScrollData): boolean\n}\n\ntype IframeResizerProps = IFrameOptions & IframeHTMLAttributes<HTMLIFrameElement>\ntype EnrichedHtmlIframeElement = HTMLIFrameElement & { iFrameResizer: { removeListeners: () => void } }\n\nexport const IframeResizer = forwardRef((props: IframeResizerProps, ref: React.Ref<HTMLIFrameElement>) => {\n const title = props.title || 'iframe'\n const { iframeHTMLAttributes, resizerOptions } = splitProps(props)\n const iframeRef = useRef<HTMLIFrameElement>(null)\n\n useEffect(() => {\n // effects run after render, so the ref is guaranteed to be set (unless the component conditionally renders the iframe, which is not the case)\n const iframe = iframeRef.current as EnrichedHtmlIframeElement\n\n iframeResizer({ ...resizerOptions }, iframe)\n\n return () => iframe.iFrameResizer && iframe.iFrameResizer.removeListeners()\n })\n\n // make the ref provided as a prop point to the same place as the internal iframe ref.\n useImperativeHandle(ref, () => iframeRef.current as HTMLIFrameElement)\n\n return <iframe {...iframeHTMLAttributes} title={title} ref={iframeRef} />\n})\n\nIframeResizer.displayName = 'IframeResizer'\n\nconst resizerOptions = [\n 'autoResize',\n 'bodyBackground',\n 'bodyMargin',\n 'bodyPadding',\n 'checkOrigin',\n 'inPageLinks',\n 'heightCalculationMethod',\n 'interval',\n 'log',\n 'maxHeight',\n 'maxWidth',\n 'minHeight',\n 'minWidth',\n 'resizeFrom',\n 'scrolling',\n 'sizeHeight',\n 'sizeWidth',\n 'warningTimeout',\n 'tolerance',\n 'widthCalculationMethod',\n 'onClosed',\n 'onInit',\n 'onMessage',\n 'onResized',\n 'onScroll',\n]\n\nconst resizerOptionsSet = new Set(resizerOptions)\n\n/**\n * split props into the resizer library options and the native iframe attributes.\n * the code is contains many type assertions because typescript doesn't handle reduce well.\n */\nfunction splitProps(props: IframeResizerProps) {\n const split = (Object.keys(props) as Array<keyof IframeResizerProps>).reduce<{\n resizerOptions: IFrameOptions\n iframeHTMLAttributes: IframeHTMLAttributes<HTMLIFrameElement>\n }>(\n (acc, key) => {\n const value = props[key]\n if (resizerOptionsSet.has(key)) {\n if (value !== undefined) {\n acc.resizerOptions[key as keyof IFrameOptions] = props[key as keyof typeof props]\n }\n } else {\n acc.iframeHTMLAttributes[key as keyof IframeHTMLAttributes<HTMLIFrameElement>] =\n props[key as keyof typeof props]\n }\n return acc\n },\n { resizerOptions: {}, iframeHTMLAttributes: {} },\n )\n\n return split\n}\n","type LoggerOptions = {\n enableLogging: boolean | undefined\n}\n\nconst defaultOptions: LoggerOptions = {\n enableLogging: false,\n}\n\nconst PREFIX = '[CapitalOS] '\n\nexport const logger = {\n log: (message: string, options: LoggerOptions = defaultOptions) => {\n if (options.enableLogging) {\n // eslint-disable-next-line no-console\n console.log(`${PREFIX}${message}`)\n }\n },\n warn: (message: string, options: LoggerOptions = defaultOptions) => {\n if (options.enableLogging) {\n // eslint-disable-next-line no-console\n console.warn(`${PREFIX}${message}`)\n }\n },\n error: (message: string, options: LoggerOptions = defaultOptions) => {\n if (options.enableLogging) {\n // eslint-disable-next-line no-console\n console.error(`${PREFIX}${message}`)\n }\n },\n}\n","import React, { createContext, useState, useMemo, useCallback } from 'react'\n\nimport { Mfa } from '../components/mfa'\nimport { Modal } from '../components/modal'\nimport { CapitalOSError, ErrorCode } from '../error'\nimport { useMfaState } from '../hooks/use-mfa-state'\nimport { useIframe, ChildFunctions, ClientActionResult } from '../iframe-connection-hooks'\nimport { IframeResizer } from '../iframe-resizer'\nimport { MfaRequestContext, MfaResult, ActionResult, Card } from '../types'\nimport { useLogger } from './capital-os-authentication-context'\n\ninterface ActionsIframeContextValue {\n childFunctions: ChildFunctions | null\n actions: {\n freezeCard: (cardId: string) => Promise<ActionResult<Card>>\n unfreezeCard: (cardId: string) => Promise<ActionResult<Card>>\n } | null\n isLoading: boolean\n}\n\nexport const ActionsIframeContext = createContext<ActionsIframeContextValue | null>(null)\n\nexport function ActionsIframeProvider({ children }: { children: React.ReactNode }) {\n const [childFunctions, setChildFunctions] = useState<ChildFunctions | null>(null)\n const { log } = useLogger()\n\n const { requestMfa, handleMfaDone, handleMfaCancel, isMfaActive, mfaContext } = useMfaState()\n\n // Translate MfaActionResult to MfaResult for Penpal communication\n const requestMfaForPenpal = useCallback(\n async (context: MfaRequestContext): Promise<MfaResult> => {\n const actionResult = await requestMfa(context)\n\n if (actionResult.success) {\n return {\n success: true,\n }\n } else if (actionResult.canceled) {\n return {\n success: false,\n canceled: true,\n }\n } else {\n return {\n success: false,\n error: actionResult.error.message,\n }\n }\n },\n [requestMfa],\n )\n\n // Convert client ActionResult to SDK ActionResult with CapitalOSError\n const wrappedChildFunctions = useMemo(() => {\n if (!childFunctions) {\n return null\n }\n\n return {\n freezeCard: async (cardId: string): Promise<ActionResult<Card>> => {\n try {\n const result: ClientActionResult<Card> = await childFunctions.freezeCard(cardId)\n\n if (result.success) {\n return {\n success: true,\n canceled: false,\n data: result.data,\n }\n } else if (result.canceled) {\n return {\n success: false,\n canceled: true,\n }\n } else {\n return {\n success: false,\n canceled: false,\n error: new CapitalOSError({\n code: ErrorCode.internal_error,\n message: result.error,\n }),\n }\n }\n } catch (error) {\n // Handle Penpal errors (timeouts, serialization, connection issues)\n return {\n success: false,\n canceled: false,\n error: new CapitalOSError({\n code: ErrorCode.internal_error,\n message: error instanceof Error ? error.message : 'Communication error with iframe',\n }),\n }\n }\n },\n unfreezeCard: async (cardId: string): Promise<ActionResult<Card>> => {\n try {\n const result: ClientActionResult<Card> = await childFunctions.unfreezeCard(cardId)\n\n if (result.success) {\n return {\n success: true,\n canceled: false,\n data: result.data,\n }\n } else if (result.canceled) {\n return {\n success: false,\n canceled: true,\n }\n } else {\n return {\n success: false,\n canceled: false,\n error: new CapitalOSError({\n code: ErrorCode.internal_error,\n message: result.error,\n }),\n }\n }\n } catch (error) {\n // Handle Penpal errors (timeouts, serialization, connection issues)\n return {\n success: false,\n canceled: false,\n error: new CapitalOSError({\n code: ErrorCode.internal_error,\n message: error instanceof Error ? error.message : 'Communication error with iframe',\n }),\n }\n }\n },\n }\n }, [childFunctions])\n\n // Methods to pass to the iframe\n const iframeMethods = useMemo(\n () => ({\n 'system-messages': {\n requestMfa: requestMfaForPenpal,\n },\n mfa: {\n onDone: handleMfaDone,\n onCancel: handleMfaCancel,\n },\n }),\n [requestMfaForPenpal, handleMfaDone, handleMfaCancel],\n )\n\n const { isLoaded, url, connection, iframeRef } = useIframe({\n renderingContext: {\n entryPoint: 'actions',\n },\n methods: iframeMethods,\n })\n\n // Update childFunctions when connection changes\n React.useEffect(() => {\n let isMounted = true\n if (connection) {\n connection.promise.then((childApi) => {\n if (isMounted) {\n setChildFunctions(childApi)\n log('Actions iframe child functions loaded')\n }\n })\n }\n return () => {\n isMounted = false\n }\n }, [connection, log])\n\n // Consider loaded only when both iframe is loaded AND childFunctions are available\n const isLoading = !isLoaded || !childFunctions\n\n return (\n <ActionsIframeContext.Provider value={{ childFunctions, actions: wrappedChildFunctions, isLoading }}>\n {children}\n {url && <IframeResizer src={url} style={{ display: 'none' }} checkOrigin={false} ref={iframeRef} />}\n\n {/* MFA Modal */}\n {isMfaActive && mfaContext && (\n <Modal onClose={handleMfaCancel} ariaLabel=\"Multi-factor authentication\">\n <Mfa\n mfaId={mfaContext.mfaId}\n destination={mfaContext.destination}\n codeLength={mfaContext.codeLength}\n canResendAfter={mfaContext.canResendAfter}\n {...(mfaContext.operationName && { operationName: mfaContext.operationName })}\n onDone={handleMfaDone}\n onCancel={handleMfaCancel}\n />\n </Modal>\n )}\n </ActionsIframeContext.Provider>\n )\n}\n","import React from 'react'\nimport { useMemo } from 'react'\n\nimport { CapitalOS } from '../capital-os'\nimport { EntryPoint } from '../external-types'\nimport { CommonProps } from '../types'\n\nexport type MfaProps = CommonProps & {\n /**\n * The ID of the MFA request.\n */\n mfaId: string\n /**\n * The destination of the MFA request.\n */\n destination: string\n /**\n * The length of the code to be entered.\n */\n codeLength: number\n /**\n * ISO string representation of DateTime in UTC\n */\n canResendAfter: string\n /**\n * The name of the operation that is being performed.\n */\n operationName?: string\n /**\n * Callback to invoke when the MFA was successfully completed.\n */\n onDone: () => void\n /**\n * Callback to invoke when the MFA was cancelled by the user.\n */\n onCancel: () => void\n}\n\nexport function Mfa({\n onDone,\n onCancel,\n mfaId,\n destination,\n codeLength,\n canResendAfter,\n operationName,\n ...restOfProps\n}: MfaProps) {\n const entryPoint: EntryPoint = 'mfa'\n const renderingContext = useMemo(\n () => ({ entryPoint, mfaId, destination, codeLength, canResendAfter, operationName }),\n [entryPoint, mfaId, destination, codeLength, canResendAfter, operationName],\n )\n\n return <CapitalOS {...restOfProps} renderingContext={renderingContext} methods={{ mfa: { onDone, onCancel } }} />\n}\n","import React, { ReactNode, useEffect } from 'react'\nimport { CSSProperties } from 'react'\n\nconst styles: Record<string, CSSProperties> = {\n backdrop: {\n position: 'fixed',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n backgroundColor: 'rgba(0, 0, 0, 0.4)',\n backdropFilter: 'blur(2px)',\n zIndex: 1000,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n padding: '20px',\n },\n container: {\n backgroundColor: 'white',\n borderRadius: '8px',\n boxShadow: '0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -2px rgb(0 0 0 / 0.05)',\n maxWidth: '600px',\n width: '100%',\n maxHeight: '90vh',\n overflow: 'hidden',\n position: 'relative',\n },\n}\n\nexport interface ModalProps {\n /**\n * Callback when modal should be closed (backdrop click)\n */\n onClose: () => void\n /**\n * Content to render inside the modal\n */\n children: ReactNode\n /**\n * Accessible label for screen readers\n */\n ariaLabel?: string\n}\n\n/**\n * Generic modal component that displays content with backdrop/blur\n */\nexport function Modal({ onClose, children, ariaLabel = 'Modal dialog' }: ModalProps) {\n // Handle Escape key press to close modal\n useEffect(() => {\n const handleEscapeKey = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n onClose()\n }\n }\n\n document.addEventListener('keydown', handleEscapeKey)\n\n // Cleanup event listener on unmount\n return () => {\n document.removeEventListener('keydown', handleEscapeKey)\n }\n }, [onClose])\n\n const handleBackdropClick = (e: React.MouseEvent) => {\n // Only trigger close if clicking directly on backdrop, not on modal content\n if (e.target === e.currentTarget) {\n onClose()\n }\n }\n\n return (\n <div\n style={styles['backdrop']}\n onClick={handleBackdropClick}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={ariaLabel}\n >\n <div style={styles['container']}>{children}</div>\n </div>\n )\n}\n","import { useState, useCallback } from 'react'\n\nimport { useLogger } from '../context/capital-os-authentication-context'\nimport { CapitalOSError } from '../error'\nimport { MfaRequestContext, MfaActionResult } from '../types'\n\ninterface MfaState {\n context: MfaRequestContext\n resolve: (result: MfaActionResult) => void\n reject: (error: Error) => void\n}\n\nexport function useMfaState() {\n const [activeMfaRequest, setActiveMfaRequest] = useState<MfaState | null>(null)\n const { log } = useLogger()\n\n // Main function to request MFA\n const requestMfa = useCallback(\n (context: MfaRequestContext): Promise<MfaActionResult> => {\n log('MFA requested')\n return new Promise((resolve, reject) => {\n setActiveMfaRequest({ context, resolve, reject })\n })\n },\n [log],\n )\n\n // Handle MFA completion\n const handleMfaDone = useCallback(() => {\n if (activeMfaRequest) {\n log('MFA completed successfully')\n activeMfaRequest.resolve({\n success: true,\n canceled: false,\n data: undefined,\n })\n setActiveMfaRequest(null)\n }\n }, [activeMfaRequest, log])\n\n // Handle MFA cancellation\n const handleMfaCancel = useCallback(() => {\n if (activeMfaRequest) {\n log('MFA canceled')\n activeMfaRequest.resolve({\n success: false,\n canceled: true,\n })\n setActiveMfaRequest(null)\n }\n }, [activeMfaRequest, log])\n\n // Handle MFA errors\n const handleMfaError = useCallback(\n (error: CapitalOSError) => {\n if (activeMfaRequest) {\n log('MFA error: ' + error.message)\n activeMfaRequest.resolve({\n success: false,\n canceled: false,\n error,\n })\n setActiveMfaRequest(null)\n }\n },\n [activeMfaRequest, log],\n )\n\n // Computed values\n const isMfaActive = !!activeMfaRequest\n const mfaContext = activeMfaRequest?.context ?? null\n\n return {\n // State\n activeMfaRequest,\n isMfaActive,\n mfaContext,\n\n // Actions\n requestMfa,\n handleMfaDone,\n handleMfaCancel,\n handleMfaError,\n }\n}\n","import React, { useMemo } from 'react'\nimport { useState } from 'react'\nimport { CSSProperties } from 'react'\n\nimport { CapitalOS } from './capital-os'\nimport { DevToolsButton } from './components/dev-tools-button'\nimport { EntryPoint } from './external-types'\nimport { CommonProps } from './types'\n\nconst styles: Record<string, CSSProperties> = {\n panel: {\n position: 'fixed',\n bottom: '20px',\n left: '20px',\n zIndex: 50,\n },\n}\n\n// #region Dev Tools\nexport type DevToolsProps = CommonProps\n\n/**\n * Renders the CapitalOS Dev Tools experience.\n * Allows for simulating transactions, etc.\n */\nexport function DevTools(props: DevToolsProps) {\n const entryPoint: EntryPoint = 'devTools'\n const renderingContext = useMemo(() => ({ entryPoint }), [entryPoint])\n\n const [isOpen, setIsOpen] = useState(false)\n\n return (\n <aside aria-label=\"CapitalOS dev tools\">\n {!isOpen && <DevToolsButton onClick={() => setIsOpen(!isOpen)} />}\n {isOpen && (\n <div style={styles['panel']}>\n <CapitalOS\n {...props}\n renderingContext={renderingContext}\n methods={{ devTools: { onClose: () => setIsOpen(false) } }}\n enableLogging={true}\n sizeWidth={true}\n loadingComponent={<DevToolsButton isLoading />}\n />\n </div>\n )}\n </aside>\n )\n}\n","import React, { useState } from 'react'\nimport { CSSProperties } from 'react'\n\nconst styles: Record<string, CSSProperties> = {\n bugButton: {\n position: 'fixed',\n left: '12px',\n bottom: '12px',\n margin: '12px',\n padding: '4px',\n display: 'inline-flex',\n alignItems: 'center',\n borderRadius: '9999px',\n border: '1px solid transparent',\n backgroundColor: '#2563eb',\n color: 'white',\n opacity: 0.4,\n boxShadow: '0 1px 3px 0 rgb(0 0 0 / 0.1)',\n cursor: 'pointer',\n zIndex: 50,\n transition: 'opacity 0.3s ease-in-out',\n },\n bugButtonHover: {\n backgroundColor: '#1d4ed8',\n opacity: 1,\n },\n bugButtonFocus: {\n outline: 'none',\n boxShadow: '0 0 0 2px white, 0 0 0 4px #3b82f6',\n },\n bugIcon: {\n width: '20px',\n height: '20px',\n },\n loadingButton: {\n cursor: 'default',\n opacity: 1,\n animation: 'pulse 1s cubic-bezier(0.4, 0, 0.6, 1) infinite',\n },\n}\n\nconst BugIcon = () => (\n <svg\n style={styles['bugIcon']}\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M12 12.75c1.148 0 2.278.08 3.383.237 1.037.146 1.866.966 1.866 2.013 0 3.728-2.35 6.75-5.25 6.75S6.75 18.728 6.75 15c0-1.046.83-1.867 1.866-2.013A24.204 24.204 0 0 1 12 12.75Zm0 0c2.883 0 5.647.508 8.207 1.44a23.91 23.91 0 0 1-1.152 6.06M12 12.75c-2.883 0-5.647.508-8.208 1.44.125 2.104.52 4.136 1.153 6.06M12 12.75a2.25 2.25 0 0 0 2.248-2.354M12 12.75a2.25 2.25 0 0 1-2.248-2.354M12 8.25c.995 0 1.971-.08 2.922-.236.403-.066.74-.358.795-.762a3.778 3.778 0 0 0-.399-2.25M12 8.25c-.995 0-1.97-.08-2.922-.236-.402-.066-.74-.358-.795-.762a3.734 3.734 0 0 1 .4-2.253M12 8.25a2.25 2.25 0 0 0-2.248 2.146M12 8.25a2.25 2.25 0 0 1 2.248 2.146M8.683 5a6.032 6.032 0 0 1-1.155-1.002c.07-.63.27-1.222.574-1.747m.581 2.749A3.75 3.75 0 0 1 15.318 5m0 0c.427-.283.815-.62 1.155-.999a4.471 4.471 0 0 0-.575-1.752M4.921 6a24.048 24.048 0 0 0-.392 3.314c1.668.546 3.416.914 5.223 1.082M19.08 6c.205 1.08.337 2.187.392 3.314a23.882 23.882 0 0 1-5.223 1.082\"\n />\n </svg>\n)\n\ninterface DevToolsButtonProps {\n onClick?: () => void\n isLoading?: boolean\n}\n\nexport function DevToolsButton({ onClick, isLoading = false }: DevToolsButtonProps) {\n const [isHovered, setIsHovered] = useState(false)\n const [isFocused, setIsFocused] = useState(false)\n\n const buttonStyle = {\n ...styles['bugButton'],\n ...(isLoading && styles['loadingButton']),\n ...(!isLoading && isHovered && styles['bugButtonHover']),\n ...(!isLoading && isFocused && styles['bugButtonFocus']),\n }\n\n if (isLoading) {\n return (\n <div style={buttonStyle}>\n <style>\n {`\n @keyframes pulse {\n 0%, 100% {\n opacity: 1;\n }\n 50% {\n opacity: 0.4;\n }\n }\n `}\n </style>\n <BugIcon />\n </div>\n )\n }\n\n return (\n <button\n id=\"dev-tools-button\"\n onClick={onClick}\n type=\"button\"\n style={buttonStyle}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n onFocus={() => setIsFocused(true)}\n onBlur={() => setIsFocused(false)}\n >\n <BugIcon />\n </button>\n )\n}\n"],"mappings":"wzBAEA,OAAOA,GAAS,WAAAC,EAAS,cAAAC,OAAkB,QCF3C,OAAOC,MAAW,QCElB,OAAOC,GAAS,iBAAAC,GAAe,cAAAC,GAAY,YAAAC,EAAU,WAAAC,GAAS,eAAAC,EAAa,aAAAC,OAAiB,QCF5F,OAAOC,IAAS,WAAAC,GAAS,UAAAC,OAAc,QCGhC,IAAMC,EAAN,cAA6B,KAAM,CAExC,YAAY,CAAE,QAAAC,EAAS,KAAAC,CAAK,EAAyC,CACnE,MAAMD,CAAO,EACb,KAAK,KAAO,iBACZ,KAAK,KAAOC,CACd,CACF,EAEaC,EAAY,CACvB,aAAc,eACd,uBAAwB,yBACxB,wBAAyB,0BACzB,eAAgB,gBAClB,EAOaC,EAAN,cAAgCJ,CAAe,CACpD,YAAYC,EAAkB,CAC5B,MAAM,CAAE,QAAS,iBAAiBA,GAAA,KAAAA,EAAW,EAAE,GAAI,KAAME,EAAU,YAAa,CAAC,EACjF,KAAK,KAAO,4BACd,CACF,EC7BA,OAAS,kBAAAE,OAAkC,SAC3C,OAAS,eAAAC,GAAa,aAAAC,EAAW,WAAAC,GAAS,UAAAC,EAAQ,YAAAC,OAAgB,QCChE,IAAAC,GAAW,aCYN,SAASC,GAA0BC,EAAkC,CAC1E,IAAMC,EAAuB,KAAK,UAAUD,CAAgB,EACtDE,EAAyB,KAAKD,CAAoB,EAGxD,OAFgC,mBAAmBC,C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,OAAAL,CAAO,CAAE,GAAG,CAClH,CAUO,SAASa,GAAYf,EAA+D,CAA/D,IAAAC,EAAAD,EAAE,QAAAgB,EAAQ,OAAAd,EAAQ,QAAAe,CAzV9C,EAyV4BhB,EAA8BG,EAAAC,EAA9BJ,EAA8B,CAA5B,SAAQ,SAAQ,YAC5C,IAAMK,EAAyB,cACzBC,EAAmBC,EAAQ,KAAO,CAAE,WAAAF,EAAY,OAAAU,CAAO,GAAI,CAACA,CAAM,CAAC,EAEzE,OACEP,EAAA,cAACC,EAAAC,EAAAC,EAAA,GAAcR,GAAd,CAA2B,iBAAkBG,EAAkB,QAAS,CAAE,YAAa,CAAE,OAAAL,EAAQ,QAAAe,CAAQ,CAAE,GAAG,CAEnH,CAUO,SAASC,GAAclB,EAAiE,CAAjE,IAAAC,EAAAD,EAAE,QAAAgB,EAAQ,OAAAd,EAAQ,QAAAe,CA1WhD,EA0W8BhB,EAA8BG,EAAAC,EAA9BJ,EAA8B,CAA5B,SAAQ,SAAQ,YAC9C,IAAMK,EAAyB,gBACzBC,EAAmBC,EAAQ,KAAO,CAAE,WAAAF,EAAY,OAAAU,CAAO,GAAI,CAACA,CAAM,CAAC,EAEzE,OACEP,EAAA,cAACC,EAAAC,EAAAC,EAAA,GAAcR,GAAd,CAA2B,iBAAkBG,EAAkB,QAAS,CAAE,cAAe,CAAE,OAAAL,EAAQ,QAAAe,CAAQ,CAAE,GAAG,CAErH,CA0BO,SAASE,IAAa,CAC3B,IAAMC,EAAUC,GAAWC,EAAoB,EAE/C,GAAI,CAACF,EACH,MAAM,IAAIG,EAAe,CACvB,QAAS,mEACT,KAAMC,EAAU,cAClB,CAAC,EAGH,GAAM,CAAE,eAAAC,EAAgB,UAAAC,CAAU,EAAIN,EAEtC,MAAO,CACL,QAASK,EACT,UAAAC,CACF,CACF","names":["React","useMemo","useContext","React","React","createContext","useContext","useState","useMemo","useCallback","useEffect","React","useMemo","useRef","CapitalOSError","message","code","ErrorCode","InvalidTokenError","connectToChild","useCallback","useEffect","useMemo","useRef","useState","version","encodeRenderingContext","renderingContext","renderingContextJson","renderingContextBase64","decodeOneTimeToken","token","urlDecodedToken","base64DecodedToken","error","InvalidTokenError","safeDecodeURIComponent","str","e","buildIframeUrl","tokenData","theme","onError","enrichedRenderingContext","__spreadProps","__spreadValues","encodedRenderingContext","url","decodedToken","version","tokenDataFromOneTimeToken","oneTimeToken","path","IFRAME_CONNECTION_TIMEOUT_MILLISECONDS","useIframeConnection","iframeRef","token","onError","methods","connection","setConnection","useState","useEffect","newConnection","connectToChild","error","useIframeUrl","tokenData","renderingContext","theme","onErrorRef","useRef","renderingContextRef","useMemo","buildIframeUrl","useIframe","props","oneTimeToken","enableLoggingProp","contextTokenData","invalidateToken","useCapitalOsAuthContext","log","warn","useLogger","isLoaded","setIsLoaded","useErrorHandling","tokenDataFromOneTimeToken","handleTokenExpired","useCallback","CapitalOSError","ErrorCode","url","__spreadValues","err","errorFired","iframeResizer","React","forwardRef","useEffect","useImperativeHandle","useRef","IframeResizer","forwardRef","props","ref","title","iframeHTMLAttributes","resizerOptions","splitProps","iframeRef","useRef","useEffect","iframe","iframeResizer","__spreadValues","useImperativeHandle","React","__spreadProps","resizerOptionsSet","acc","key","value","TokenExchangeIframe","props","oneTimeToken","enableLogging","onExchangeComplete","onExchangeError","enableLoggingResolved","useEnableLogging","iframeRef","useRef","tokenData","useMemo","tokenDataFromOneTimeToken","url","useIframeUrl","useIframeConnection","error","CapitalOSError","React","IframeResizer","defaultOptions","PREFIX","logger","message","options","React","createContext","useState","useMemo","useCallback","React","useMemo","Mfa","_a","_b","onDone","onCancel","mfaId","destination","codeLength","canResendAfter","operationName","restOfProps","__objRest","entryPoint","renderingContext","useMemo","React","CapitalOS","__spreadProps","__spreadValues","React","useEffect","styles","Modal","onClose","children","ariaLabel","handleEscapeKey","event","handleBackdropClick","e","useState","useCallback","useMfaState","_a","activeMfaRequest","setActiveMfaRequest","useState","log","useLogger","requestMfa","useCallback","context","resolve","reject","handleMfaDone","handleMfaCancel","handleMfaError","error","isMfaActive","mfaContext","ActionsIframeContext","createContext","ActionsIframeProvider","children","childFunctions","setChildFunctions","useState","log","useLogger","requestMfa","handleMfaDone","handleMfaCancel","isMfaActive","mfaContext","useMfaState","requestMfaForPenpal","useCallback","context","__async","actionResult","wrappedChildFunctions","useMemo","cardId","result","CapitalOSError","ErrorCode","error","iframeMethods","isLoaded","url","connection","iframeRef","useIframe","React","isMounted","childApi","isLoading","IframeResizer","Modal","Mfa","__spreadProps","__spreadValues","CapitalOsAuthenticationContext","createContext","CapitalOsAuthenticationProvider","getToken","enableLogging","children","oneTimeToken","setOneTimeToken","useState","baseUrl","setBaseUrl","longLivedToken","setLongLivedToken","isLoading","setIsLoading","error","setError","refreshOneTimeToken","useCallback","__async","newToken","tokenObject","decodeOneTimeToken","url","invalidateToken","useEffect","onExchangeComplete","jwtToken","contextValue","useMemo","CapitalOSError","ErrorCode","React","ActionsIframeProvider","TokenExchangeIframe","useCapitalOsAuthContext","useContext","useEnableLogging","enableLoggingProp","contextEnableLogging","useLogger","log","message","logger","warn","CapitalOS","props","tokenProp","className","enableLogging","onError","LoadingComponent","renderingContext","methods","theme","sizeWidth","enableLoggingResolved","useEnableLogging","isLoaded","url","tokenData","iframeRef","useIframe","React","shouldAddPaddingBottom","IframeResizer","data","newHeight","React","useMemo","useState","React","useState","styles","BugIcon","React","DevToolsButton","onClick","isLoading","isHovered","setIsHovered","useState","isFocused","setIsFocused","buttonStyle","__spreadValues","styles","DevTools","props","entryPoint","renderingContext","useMemo","isOpen","setIsOpen","useState","React","DevToolsButton","CapitalOS","__spreadProps","__spreadValues","CardsApp","props","entryPoint","renderingContext","useMemo","React","CapitalOS","__spreadProps","__spreadValues","App","IssueCard","_a","_b","cardholder","onDone","onCancel","restOfProps","__objRest","entryPoint","renderingContext","useMemo","React","CapitalOS","__spreadProps","__spreadValues","DisputeTransaction","transactionId","BillPayApp","props","CardDetails","onCardCanceled","AccountDetails","AccountActions","InsightsDashboard","InsightsWidget","widget","hideTitle","height","width","Onboarding","onboardingEntryPoint","onboardingExitPoint","MakePayment","ContactSupport","_a","_b","onDone","onCancel","restOfProps","__objRest","entryPoint","renderingContext","useMemo","React","CapitalOS","__spreadProps","__spreadValues","Statements","LegalDocuments","ReplaceCard","cardId","onClose","TerminateCard","useActions","context","useContext","ActionsIframeContext","CapitalOSError","ErrorCode","childFunctions","isLoading"]}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";"use client";var pe=Object.create;var A=Object.defineProperty,me=Object.defineProperties,le=Object.getOwnPropertyDescriptor,ue=Object.getOwnPropertyDescriptors,fe=Object.getOwnPropertyNames,_=Object.getOwnPropertySymbols,ge=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable;var q=(e,t,o)=>t in e?A(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,a=(e,t)=>{for(var o in t||(t={}))V.call(t,o)&&q(e,o,t[o]);if(_)for(var o of _(t))Z.call(t,o)&&q(e,o,t[o]);return e},m=(e,t)=>me(e,ue(t));var D=(e,t)=>{var o={};for(var n in e)V.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&_)for(var n of _(e))t.indexOf(n)<0&&Z.call(e,n)&&(o[n]=e[n]);return o};var he=(e,t)=>{for(var o in t)A(e,o,{get:t[o],enumerable:!0})},G=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of fe(t))!V.call(e,r)&&r!==o&&A(e,r,{get:()=>t[r],enumerable:!(n=le(t,r))||n.enumerable});return e};var v=(e,t,o)=>(o=e!=null?pe(ge(e)):{},G(t||!e||!e.__esModule?A(o,"default",{value:e,enumerable:!0}):o,e)),Ce=e=>G(A({},"__esModule",{value:!0}),e);var Q=(e,t,o)=>new Promise((n,r)=>{var i=u=>{try{c(o.next(u))}catch(h){r(h)}},s=u=>{try{c(o.throw(u))}catch(h){r(h)}},c=u=>u.done?n(u.value):Promise.resolve(u.value).then(i,s);c((o=o.apply(e,t)).next())});var Ne={};he(Ne,{AccountActions:()=>Re,AccountDetails:()=>Fe,App:()=>we,BillPayApp:()=>Se,CapitalOsAuthenticationProvider:()=>re,CardDetails:()=>ze,CardsApp:()=>ce,DevTools:()=>de,DisputeTransaction:()=>Ae,InsightsDashboard:()=>He,InsightsWidget:()=>Be,IssueCard:()=>Me,MakePayment:()=>_e,Onboarding:()=>Ue});module.exports=Ce(Ne);var d=v(require("react"));var l=v(require("react"));var p=v(require("react"));var w=v(require("react"));var C=class extends Error{constructor({message:t,code:o}){super(t),this.name="CapitalOSError",this.code=o}},S={unauthorized:"unauthorized",invalid_account_status:"invalid_account_status",unsupported_entry_point:"unsupported_entry_point",internal_error:"internal_error"},L=class extends C{constructor(t){super({message:`Invalid token ${t!=null?t:""}`,code:S.unauthorized}),this.name="CapitalOSInvalidTokenError"}};var ee=require("penpal"),I=require("react");var X="1.1.0-rc.1";function Pe(e){let t=JSON.stringify(e),o=btoa(t);return encodeURIComponent(o)}function J(e){try{let t=decodeURIComponent(e),o=atob(t);return JSON.parse(o)}catch(t){throw new L}}function be(e){try{return decodeURIComponent(e)}catch(t){return e}}function Y({tokenData:e,renderingContext:t,theme:o,onError:n}){try{let r=t?m(a({},t),{referer:window.location.href}):null,i=r?Pe(r):null,s=new URL(e.baseUrl),c=be(e.token);return e.paramLocation==="search"?s.searchParams.set(e.paramKey,c):e.paramLocation==="hash"&&(s.hash=e.paramKey+"="+encodeURIComponent(c)),s.searchParams.set("sdkVersion",X),i&&s.searchParams.set("renderingContext",i),o&&s.searchParams.set("theme",o),s.toString()}catch(r){n==null||n(new L);return}}function N(e){let o=J(e).path;if(!o||typeof o!="string")throw new L;return{token:e,tokenType:"oneTime",baseUrl:o,paramKey:"token",paramLocation:"search"}}var ve=1e4;function W({iframeRef:e,token:t,onError:o,methods:n}){(0,I.useEffect)(()=>{if(!e.current)return;let r=(0,ee.connectToChild)({iframe:e.current,childOrigin:"*",debug:!0,timeout:ve,methods:n});return r.promise.catch(i=>{o==null||o(i)}),()=>{r.destroy()}},[t,e])}function j({tokenData:e,renderingContext:t,theme:o,onError:n}){let r=(0,I.useRef)(n),i=(0,I.useRef)(t);return(0,I.useMemo)(()=>{if(e)return Y({tokenData:e,renderingContext:i.current,theme:o,onError:r.current})},[e,o,r,i])}var te=require("iframe-resizer"),x=v(require("react"));var z=(0,x.forwardRef)((e,t)=>{let o=e.title||"iframe",{iframeHTMLAttributes:n,resizerOptions:r}=Oe(e),i=(0,x.useRef)(null);return(0,x.useEffect)(()=>{let s=i.current;return(0,te.iframeResizer)(a({},r),s),()=>s.iFrameResizer&&s.iFrameResizer.removeListeners()}),(0,x.useImperativeHandle)(t,()=>i.current),x.default.createElement("iframe",m(a({},n),{title:o,ref:i}))});z.displayName="IframeResizer";var Ie=["autoResize","bodyBackground","bodyMargin","bodyPadding","checkOrigin","inPageLinks","heightCalculationMethod","interval","log","maxHeight","maxWidth","minHeight","minWidth","resizeFrom","scrolling","sizeHeight","sizeWidth","warningTimeout","tolerance","widthCalculationMethod","onClosed","onInit","onMessage","onResized","onScroll"],Ee=new Set(Ie);function Oe(e){return Object.keys(e).reduce((o,n)=>{let r=e[n];return Ee.has(n)?r!==void 0&&(o.resizerOptions[n]=e[n]):o.iframeHTMLAttributes[n]=e[n],o},{resizerOptions:{},iframeHTMLAttributes:{}})}function oe(e){let{oneTimeToken:t,enableLogging:o,onExchangeComplete:n,onExchangeError:r}=e,i=(0,w.useRef)(null),s=(0,w.useMemo)(()=>N(t),[t]),u=j({tokenData:s,onError:r,renderingContext:{entryPoint:"tokenExchange"}});return W({iframeRef:i,token:t,onError:r,methods:{onLoad:()=>{},onError:h=>{r==null||r(new C(h))},tokenExchange:{onLongLivedToken:n}}}),w.default.createElement(z,{src:u,checkOrigin:!1,style:{display:"none"},log:!!o,ref:i})}var ne=(0,p.createContext)({isLoading:!1,invalidateToken:()=>{}}),re=({getToken:e,enableLogging:t,children:o})=>{let[n,r]=(0,p.useState)(void 0),[i,s]=(0,p.useState)(void 0),[c,u]=(0,p.useState)(void 0),[h,k]=(0,p.useState)(!1),[R,P]=(0,p.useState)(void 0),M=(0,p.useCallback)(()=>Q(void 0,null,function*(){k(!0);try{let y=yield e();r(y),P(void 0);let B=J(y),U=new URL(B.path);U.pathname="",s(U.toString())}catch(y){P(y)}finally{k(!1)}}),[e]),E=(0,p.useCallback)(()=>{u(void 0)},[]);(0,p.useEffect)(()=>{c||M()},[c,M]);let H=(0,p.useCallback)(y=>{u(y),r(void 0),P(void 0)},[]),b=(0,p.useMemo)(()=>{if(c&&!i)throw new C({message:"baseUrl is required for long lived tokens",code:S.unauthorized});return{tokenData:c?{token:c,tokenType:"longLived",baseUrl:i,paramKey:"access_token",paramLocation:"hash"}:void 0,isLoading:h,error:R,invalidateToken:E}},[c,h,R,E,i]);return p.default.createElement(p.default.Fragment,null,p.default.createElement(ne.Provider,{value:b},o),n&&!c&&p.default.createElement(oe,{oneTimeToken:n,onExchangeComplete:H,enableLogging:t,onExchangeError:P}))},ie=()=>(0,p.useContext)(ne);function f(e){let{token:t,className:o,enableLogging:n,onError:r,loadingComponent:i,renderingContext:s,methods:c,theme:u,sizeWidth:h}=e,{tokenData:k,error:R,invalidateToken:P}=ie(),[M,E]=(0,l.useState)(!1),H=(0,l.useRef)(null);De(R,r);let b=(0,l.useMemo)(()=>t?N(t):k,[t,k]),y=(0,l.useCallback)(()=>{if(n&&console.log("CapitalOS: Token expired, invalidating..."),t){r==null||r(new C({message:"Token expired. Cannot automatically refresh when using token prop.",code:S.unauthorized}));return}P(),E(!1)},[t,P,n,r]);(0,l.useEffect)(()=>{t&&k&&n&&console.warn("CapitalOS: token was provided both from provider and from the token prop. the prop will take precedence")},[t,k,n]);let B=j({tokenData:b,renderingContext:s,theme:u,onError:r});if(W({iframeRef:H,token:b==null?void 0:b.token,onError:O=>{r==null||r(O),E(!0)},methods:a({onLoad:()=>{E(!0)},onError:O=>{let K=new C(O);r==null||r(K)},onTokenExpired:y},c)}),!b||!B)return l.default.createElement(l.default.Fragment,null,i||null);let U=s.entryPoint!=="insightsWidget";return l.default.createElement(l.default.Fragment,null,!M&&i,l.default.createElement(z,{src:B,allow:"clipboard-write",checkOrigin:!1,style:{width:"1px",height:"0px",minWidth:"100%"},className:o,log:!!n,ref:H,hidden:!M,onResized:O=>{if(!U)return;let K=`${parseInt(O.height)+12}px`;O.iframe.style.height=K},sizeWidth:h}))}function De(e,t){let o=(0,l.useRef)(!1);(0,l.useEffect)(()=>{e&&!o.current&&(t==null||t(e),o.current=!0)},[e,t])}var T=v(require("react")),ae=require("react");var g=v(require("react"));var F={bugButton:{position:"fixed",left:"12px",bottom:"12px",margin:"12px",padding:"4px",display:"inline-flex",alignItems:"center",borderRadius:"9999px",border:"1px solid transparent",backgroundColor:"#2563eb",color:"white",opacity:.4,boxShadow:"0 1px 3px 0 rgb(0 0 0 / 0.1)",cursor:"pointer",zIndex:50,transition:"opacity 0.3s ease-in-out"},bugButtonHover:{backgroundColor:"#1d4ed8",opacity:1},bugButtonFocus:{outline:"none",boxShadow:"0 0 0 2px white, 0 0 0 4px #3b82f6"},bugIcon:{width:"20px",height:"20px"},loadingButton:{cursor:"default",opacity:1,animation:"pulse 1s cubic-bezier(0.4, 0, 0.6, 1) infinite"}},se=()=>g.default.createElement("svg",{style:F.bugIcon,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor"},g.default.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 12.75c1.148 0 2.278.08 3.383.237 1.037.146 1.866.966 1.866 2.013 0 3.728-2.35 6.75-5.25 6.75S6.75 18.728 6.75 15c0-1.046.83-1.867 1.866-2.013A24.204 24.204 0 0 1 12 12.75Zm0 0c2.883 0 5.647.508 8.207 1.44a23.91 23.91 0 0 1-1.152 6.06M12 12.75c-2.883 0-5.647.508-8.208 1.44.125 2.104.52 4.136 1.153 6.06M12 12.75a2.25 2.25 0 0 0 2.248-2.354M12 12.75a2.25 2.25 0 0 1-2.248-2.354M12 8.25c.995 0 1.971-.08 2.922-.236.403-.066.74-.358.795-.762a3.778 3.778 0 0 0-.399-2.25M12 8.25c-.995 0-1.97-.08-2.922-.236-.402-.066-.74-.358-.795-.762a3.734 3.734 0 0 1 .4-2.253M12 8.25a2.25 2.25 0 0 0-2.248 2.146M12 8.25a2.25 2.25 0 0 1 2.248 2.146M8.683 5a6.032 6.032 0 0 1-1.155-1.002c.07-.63.27-1.222.574-1.747m.581 2.749A3.75 3.75 0 0 1 15.318 5m0 0c.427-.283.815-.62 1.155-.999a4.471 4.471 0 0 0-.575-1.752M4.921 6a24.048 24.048 0 0 0-.392 3.314c1.668.546 3.416.914 5.223 1.082M19.08 6c.205 1.08.337 2.187.392 3.314a23.882 23.882 0 0 1-5.223 1.082"}));function $({onClick:e,isLoading:t=!1}){let[o,n]=(0,g.useState)(!1),[r,i]=(0,g.useState)(!1),s=a(a(a(a({},F.bugButton),t&&F.loadingButton),!t&&o&&F.bugButtonHover),!t&&r&&F.bugButtonFocus);return t?g.default.createElement("div",{style:s},g.default.createElement("style",null,`
1
+ "use strict";"use client";var Ie=Object.create;var U=Object.defineProperty,Me=Object.defineProperties,Le=Object.getOwnPropertyDescriptor,Oe=Object.getOwnPropertyDescriptors,Ae=Object.getOwnPropertyNames,$=Object.getOwnPropertySymbols,De=Object.getPrototypeOf,X=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var re=(e,t,n)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t)=>{for(var n in t||(t={}))X.call(t,n)&&re(e,n,t[n]);if($)for(var n of $(t))ie.call(t,n)&&re(e,n,t[n]);return e},u=(e,t)=>Me(e,Oe(t));var k=(e,t)=>{var n={};for(var o in e)X.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&$)for(var o of $(e))t.indexOf(o)<0&&ie.call(e,o)&&(n[o]=e[o]);return n};var we=(e,t)=>{for(var n in t)U(e,n,{get:t[n],enumerable:!0})},se=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ae(t))!X.call(e,r)&&r!==n&&U(e,r,{get:()=>t[r],enumerable:!(o=Le(t,r))||o.enumerable});return e};var O=(e,t,n)=>(n=e!=null?Ie(De(e)):{},se(t||!e||!e.__esModule?U(n,"default",{value:e,enumerable:!0}):n,e)),Se=e=>se(U({},"__esModule",{value:!0}),e);var z=(e,t,n)=>new Promise((o,r)=>{var i=p=>{try{a(n.next(p))}catch(f){r(f)}},s=p=>{try{a(n.throw(p))}catch(f){r(f)}},a=p=>p.done?o(p.value):Promise.resolve(p.value).then(i,s);a((n=n.apply(e,t)).next())});var dt={};we(dt,{AccountActions:()=>Qe,AccountDetails:()=>Ge,App:()=>Ke,BillPayApp:()=>Xe,CapitalOsAuthenticationProvider:()=>Pe,CardDetails:()=>Ze,CardsApp:()=>Te,ContactSupport:()=>ot,DevTools:()=>ke,DisputeTransaction:()=>Je,InsightsDashboard:()=>Ye,InsightsWidget:()=>et,IssueCard:()=>Ve,LegalDocuments:()=>it,MakePayment:()=>nt,Onboarding:()=>tt,ReplaceCard:()=>st,Statements:()=>rt,TerminateCard:()=>at,useActions:()=>ct});module.exports=Se(dt);var c=O(require("react"));var _=O(require("react"));var l=O(require("react"));var N=O(require("react"));var h=class extends Error{constructor({message:t,code:n}){super(t),this.name="CapitalOSError",this.code=n}},T={unauthorized:"unauthorized",invalid_account_status:"invalid_account_status",unsupported_entry_point:"unsupported_entry_point",internal_error:"internal_error"},H=class extends h{constructor(t){super({message:`Invalid token ${t!=null?t:""}`,code:T.unauthorized}),this.name="CapitalOSInvalidTokenError"}};var de=require("penpal"),y=require("react");var ae="1.2.1-rc.1";function Be(e){let t=JSON.stringify(e),n=btoa(t);return encodeURIComponent(n)}function Z(e){try{let t=decodeURIComponent(e),n=atob(t);return JSON.parse(n)}catch(t){throw new H}}function Ne(e){try{return decodeURIComponent(e)}catch(t){return e}}function ce({tokenData:e,renderingContext:t,theme:n,onError:o}){try{let r=t?u(d({},t),{referer:window.location.href}):null,i=r?Be(r):null,s=new URL(e.baseUrl),a=Ne(e.token);return e.paramLocation==="search"?s.searchParams.set(e.paramKey,a):e.paramLocation==="hash"&&(s.hash=e.paramKey+"="+encodeURIComponent(a)),s.searchParams.set("sdkVersion",ae),i&&s.searchParams.set("renderingContext",i),n&&s.searchParams.set("theme",n),s.toString()}catch(r){o==null||o(new H);return}}function K(e){let n=Z(e).path;if(!n||typeof n!="string")throw new H;return{token:e,tokenType:"oneTime",baseUrl:n,paramKey:"token",paramLocation:"search"}}var _e=1e4;function G({iframeRef:e,token:t,onError:n,methods:o}){let[r,i]=(0,y.useState)(null);return(0,y.useEffect)(()=>{if(!e.current)return;let s=(0,de.connectToChild)({iframe:e.current,childOrigin:"*",debug:!0,timeout:_e,methods:o});return s.promise.then(()=>{i(s)}).catch(a=>{n==null||n(a),i(null)}),()=>{s.destroy(),i(null)}},[t,e]),r}function Q({tokenData:e,renderingContext:t,theme:n,onError:o}){let r=(0,y.useRef)(o),i=(0,y.useRef)(t);return(0,y.useMemo)(()=>{if(e)return ce({tokenData:e,renderingContext:i.current,theme:n,onError:r.current})},[e,n,r,i])}function V(e){let{oneTimeToken:t,enableLogging:n,onError:o,renderingContext:r,theme:i,methods:s}=e,{tokenData:a,error:p,invalidateToken:f}=Y(),{log:C,warn:v}=B(n),[b,E]=(0,y.useState)(!1),I=(0,y.useRef)(null);Ue(p,o);let M=(0,y.useMemo)(()=>t?K(t):a,[t,a]),D=(0,y.useCallback)(()=>{if(C("Token expired, invalidating..."),t){o==null||o(new h({message:"Token expired. Cannot automatically refresh when using token prop.",code:T.unauthorized}));return}f(),E(!1)},[t,f,C,o]);(0,y.useEffect)(()=>{t&&a&&v("token was provided both from provider and from the token prop. the prop will take precedence")},[t,a,v]);let x=Q({tokenData:M,renderingContext:r,theme:i,onError:o}),m=G({iframeRef:I,token:M==null?void 0:M.token,onError:F=>{o==null||o(F),E(!0)},methods:d({onLoad:()=>{E(!0)},onError:F=>{let Ee=new h(F);o==null||o(Ee)},onTokenExpired:D},s)});return{isLoaded:b,url:x,tokenData:M,iframeRef:I,connection:m}}function Ue(e,t){let n=(0,y.useRef)(!1);(0,y.useEffect)(()=>{e&&!n.current&&(t==null||t(e),n.current=!0)},[e,t])}var le=require("iframe-resizer"),A=O(require("react"));var S=(0,A.forwardRef)((e,t)=>{let n=e.title||"iframe",{iframeHTMLAttributes:o,resizerOptions:r}=je(e),i=(0,A.useRef)(null);return(0,A.useEffect)(()=>{let s=i.current;return(0,le.iframeResizer)(d({},r),s),()=>s.iFrameResizer&&s.iFrameResizer.removeListeners()}),(0,A.useImperativeHandle)(t,()=>i.current),A.default.createElement("iframe",u(d({},o),{title:n,ref:i}))});S.displayName="IframeResizer";var qe=["autoResize","bodyBackground","bodyMargin","bodyPadding","checkOrigin","inPageLinks","heightCalculationMethod","interval","log","maxHeight","maxWidth","minHeight","minWidth","resizeFrom","scrolling","sizeHeight","sizeWidth","warningTimeout","tolerance","widthCalculationMethod","onClosed","onInit","onMessage","onResized","onScroll"],We=new Set(qe);function je(e){return Object.keys(e).reduce((n,o)=>{let r=e[o];return We.has(o)?r!==void 0&&(n.resizerOptions[o]=e[o]):n.iframeHTMLAttributes[o]=e[o],n},{resizerOptions:{},iframeHTMLAttributes:{}})}function pe(e){let{oneTimeToken:t,enableLogging:n,onExchangeComplete:o,onExchangeError:r}=e,i=q(n),s=(0,N.useRef)(null),a=(0,N.useMemo)(()=>K(t),[t]),f=Q({tokenData:a,onError:r,renderingContext:{entryPoint:"tokenExchange"}});return G({iframeRef:s,token:t,onError:r,methods:{onLoad:()=>{},onError:C=>{r==null||r(new h(C))},tokenExchange:{onLongLivedToken:o}}}),N.default.createElement(S,{src:f,checkOrigin:!1,style:{display:"none"},log:i,ref:s})}var ee={enableLogging:!1},te="[CapitalOS] ",J={log:(e,t=ee)=>{t.enableLogging&&console.log(`${te}${e}`)},warn:(e,t=ee)=>{t.enableLogging&&console.warn(`${te}${e}`)},error:(e,t=ee)=>{t.enableLogging&&console.error(`${te}${e}`)}};var P=O(require("react"));var ue=O(require("react")),me=require("react");function fe(p){var f=p,{onDone:e,onCancel:t,mfaId:n,destination:o,codeLength:r,canResendAfter:i,operationName:s}=f,a=k(f,["onDone","onCancel","mfaId","destination","codeLength","canResendAfter","operationName"]);let C="mfa",v=(0,me.useMemo)(()=>({entryPoint:C,mfaId:n,destination:o,codeLength:r,canResendAfter:i,operationName:s}),[C,n,o,r,i,s]);return ue.default.createElement(g,u(d({},a),{renderingContext:v,methods:{mfa:{onDone:e,onCancel:t}}}))}var W=O(require("react")),ge={backdrop:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.4)",backdropFilter:"blur(2px)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",padding:"20px"},container:{backgroundColor:"white",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -2px rgb(0 0 0 / 0.05)",maxWidth:"600px",width:"100%",maxHeight:"90vh",overflow:"hidden",position:"relative"}};function Ce({onClose:e,children:t,ariaLabel:n="Modal dialog"}){(0,W.useEffect)(()=>{let r=i=>{i.key==="Escape"&&e()};return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[e]);let o=r=>{r.target===r.currentTarget&&e()};return W.default.createElement("div",{style:ge.backdrop,onClick:o,role:"dialog","aria-modal":"true","aria-label":n},W.default.createElement("div",{style:ge.container},t))}var R=require("react");function xe(){var f;let[e,t]=(0,R.useState)(null),{log:n}=B(),o=(0,R.useCallback)(C=>(n("MFA requested"),new Promise((v,b)=>{t({context:C,resolve:v,reject:b})})),[n]),r=(0,R.useCallback)(()=>{e&&(n("MFA completed successfully"),e.resolve({success:!0,canceled:!1,data:void 0}),t(null))},[e,n]),i=(0,R.useCallback)(()=>{e&&(n("MFA canceled"),e.resolve({success:!1,canceled:!0}),t(null))},[e,n]),s=(0,R.useCallback)(C=>{e&&(n("MFA error: "+C.message),e.resolve({success:!1,canceled:!1,error:C}),t(null))},[e,n]),a=!!e,p=(f=e==null?void 0:e.context)!=null?f:null;return{activeMfaRequest:e,isMfaActive:a,mfaContext:p,requestMfa:o,handleMfaDone:r,handleMfaCancel:i,handleMfaError:s}}var ne=(0,P.createContext)(null);function he({children:e}){let[t,n]=(0,P.useState)(null),{log:o}=B(),{requestMfa:r,handleMfaDone:i,handleMfaCancel:s,isMfaActive:a,mfaContext:p}=xe(),f=(0,P.useCallback)(x=>z(this,null,function*(){let m=yield r(x);return m.success?{success:!0}:m.canceled?{success:!1,canceled:!0}:{success:!1,error:m.error.message}}),[r]),C=(0,P.useMemo)(()=>t?{freezeCard:x=>z(this,null,function*(){try{let m=yield t.freezeCard(x);return m.success?{success:!0,canceled:!1,data:m.data}:m.canceled?{success:!1,canceled:!0}:{success:!1,canceled:!1,error:new h({code:T.internal_error,message:m.error})}}catch(m){return{success:!1,canceled:!1,error:new h({code:T.internal_error,message:m instanceof Error?m.message:"Communication error with iframe"})}}}),unfreezeCard:x=>z(this,null,function*(){try{let m=yield t.unfreezeCard(x);return m.success?{success:!0,canceled:!1,data:m.data}:m.canceled?{success:!1,canceled:!0}:{success:!1,canceled:!1,error:new h({code:T.internal_error,message:m.error})}}catch(m){return{success:!1,canceled:!1,error:new h({code:T.internal_error,message:m instanceof Error?m.message:"Communication error with iframe"})}}})}:null,[t]),v=(0,P.useMemo)(()=>({"system-messages":{requestMfa:f},mfa:{onDone:i,onCancel:s}}),[f,i,s]),{isLoaded:b,url:E,connection:I,iframeRef:M}=V({renderingContext:{entryPoint:"actions"},methods:v});P.default.useEffect(()=>{let x=!0;return I&&I.promise.then(m=>{x&&(n(m),o("Actions iframe child functions loaded"))}),()=>{x=!1}},[I,o]);let D=!b||!t;return P.default.createElement(ne.Provider,{value:{childFunctions:t,actions:C,isLoading:D}},e,E&&P.default.createElement(S,{src:E,style:{display:"none"},checkOrigin:!1,ref:M}),a&&p&&P.default.createElement(Ce,{onClose:s,ariaLabel:"Multi-factor authentication"},P.default.createElement(fe,u(d({mfaId:p.mfaId,destination:p.destination,codeLength:p.codeLength,canResendAfter:p.canResendAfter},p.operationName&&{operationName:p.operationName}),{onDone:i,onCancel:s}))))}var ye=(0,l.createContext)({isLoading:!1,invalidateToken:()=>{},enableLogging:!1}),Pe=({getToken:e,enableLogging:t,children:n})=>{let[o,r]=(0,l.useState)(void 0),[i,s]=(0,l.useState)(void 0),[a,p]=(0,l.useState)(void 0),[f,C]=(0,l.useState)(!1),[v,b]=(0,l.useState)(void 0),E=(0,l.useCallback)(()=>z(void 0,null,function*(){C(!0);try{let x=yield e();r(x),b(void 0);let m=Z(x),F=new URL(m.path);F.pathname="",s(F.toString())}catch(x){b(x)}finally{C(!1)}}),[e]),I=(0,l.useCallback)(()=>{p(void 0)},[]);(0,l.useEffect)(()=>{a||E()},[a,E]);let M=(0,l.useCallback)(x=>{p(x),r(void 0),b(void 0)},[]),D=(0,l.useMemo)(()=>{if(a&&!i)throw new h({message:"baseUrl is required for long lived tokens",code:T.unauthorized});return{tokenData:a?{token:a,tokenType:"longLived",baseUrl:i,paramKey:"access_token",paramLocation:"hash"}:void 0,isLoading:f,error:v,invalidateToken:I,enableLogging:t!=null?t:!1}},[a,f,v,I,i,t]);return l.default.createElement(l.default.Fragment,null,l.default.createElement(ye.Provider,{value:D},l.default.createElement(he,null,n)),o&&!a&&l.default.createElement(pe,{oneTimeToken:o,onExchangeComplete:M,enableLogging:t,onExchangeError:b}))},Y=()=>(0,l.useContext)(ye);function q(e){let{enableLogging:t}=Y();return e!==void 0?e:t}function B(e){let t=q(e),n=(0,l.useCallback)(i=>{J.log(i,{enableLogging:t})},[t]),o=(0,l.useCallback)(i=>{J.warn(i,{enableLogging:t})},[t]),r=(0,l.useCallback)(i=>{J.error(i,{enableLogging:t})},[t]);return(0,l.useMemo)(()=>({log:n,warn:o,error:r}),[n,o,r])}function g(e){let{token:t,className:n,enableLogging:o,onError:r,loadingComponent:i,renderingContext:s,methods:a,theme:p,sizeWidth:f}=e,C=q(o),{isLoaded:v,url:b,tokenData:E,iframeRef:I}=V({oneTimeToken:t,enableLogging:C,onError:r,renderingContext:s,theme:p,methods:a});if(!E||!b)return _.default.createElement(_.default.Fragment,null,i||null);let M=s.entryPoint!=="insightsWidget";return _.default.createElement(_.default.Fragment,null,!v&&i,_.default.createElement(S,{src:b,allow:"clipboard-write",checkOrigin:!1,style:{width:"1px",height:"0px",minWidth:"100%"},className:n,log:C,ref:I,hidden:!v,onResized:D=>{if(!M)return;let x=`${parseInt(D.height)+12}px`;D.iframe.style.height=x},sizeWidth:f}))}var w=O(require("react")),be=require("react");var L=O(require("react"));var j={bugButton:{position:"fixed",left:"12px",bottom:"12px",margin:"12px",padding:"4px",display:"inline-flex",alignItems:"center",borderRadius:"9999px",border:"1px solid transparent",backgroundColor:"#2563eb",color:"white",opacity:.4,boxShadow:"0 1px 3px 0 rgb(0 0 0 / 0.1)",cursor:"pointer",zIndex:50,transition:"opacity 0.3s ease-in-out"},bugButtonHover:{backgroundColor:"#1d4ed8",opacity:1},bugButtonFocus:{outline:"none",boxShadow:"0 0 0 2px white, 0 0 0 4px #3b82f6"},bugIcon:{width:"20px",height:"20px"},loadingButton:{cursor:"default",opacity:1,animation:"pulse 1s cubic-bezier(0.4, 0, 0.6, 1) infinite"}},ve=()=>L.default.createElement("svg",{style:j.bugIcon,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor"},L.default.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 12.75c1.148 0 2.278.08 3.383.237 1.037.146 1.866.966 1.866 2.013 0 3.728-2.35 6.75-5.25 6.75S6.75 18.728 6.75 15c0-1.046.83-1.867 1.866-2.013A24.204 24.204 0 0 1 12 12.75Zm0 0c2.883 0 5.647.508 8.207 1.44a23.91 23.91 0 0 1-1.152 6.06M12 12.75c-2.883 0-5.647.508-8.208 1.44.125 2.104.52 4.136 1.153 6.06M12 12.75a2.25 2.25 0 0 0 2.248-2.354M12 12.75a2.25 2.25 0 0 1-2.248-2.354M12 8.25c.995 0 1.971-.08 2.922-.236.403-.066.74-.358.795-.762a3.778 3.778 0 0 0-.399-2.25M12 8.25c-.995 0-1.97-.08-2.922-.236-.402-.066-.74-.358-.795-.762a3.734 3.734 0 0 1 .4-2.253M12 8.25a2.25 2.25 0 0 0-2.248 2.146M12 8.25a2.25 2.25 0 0 1 2.248 2.146M8.683 5a6.032 6.032 0 0 1-1.155-1.002c.07-.63.27-1.222.574-1.747m.581 2.749A3.75 3.75 0 0 1 15.318 5m0 0c.427-.283.815-.62 1.155-.999a4.471 4.471 0 0 0-.575-1.752M4.921 6a24.048 24.048 0 0 0-.392 3.314c1.668.546 3.416.914 5.223 1.082M19.08 6c.205 1.08.337 2.187.392 3.314a23.882 23.882 0 0 1-5.223 1.082"}));function oe({onClick:e,isLoading:t=!1}){let[n,o]=(0,L.useState)(!1),[r,i]=(0,L.useState)(!1),s=d(d(d(d({},j.bugButton),t&&j.loadingButton),!t&&n&&j.bugButtonHover),!t&&r&&j.bugButtonFocus);return t?L.default.createElement("div",{style:s},L.default.createElement("style",null,`
2
2
  @keyframes pulse {
3
3
  0%, 100% {
4
4
  opacity: 1;
@@ -7,5 +7,5 @@
7
7
  opacity: 0.4;
8
8
  }
9
9
  }
10
- `),g.default.createElement(se,null)):g.default.createElement("button",{id:"dev-tools-button",onClick:e,type:"button",style:s,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),onFocus:()=>i(!0),onBlur:()=>i(!1)},g.default.createElement(se,null))}var Le={panel:{position:"fixed",bottom:"20px",left:"20px",zIndex:50}};function de(e){let t="devTools",o=(0,T.useMemo)(()=>({entryPoint:t}),[t]),[n,r]=(0,ae.useState)(!1);return T.default.createElement("aside",{"aria-label":"CapitalOS dev tools"},!n&&T.default.createElement($,{onClick:()=>r(!n)}),n&&T.default.createElement("div",{style:Le.panel},T.default.createElement(f,m(a({},e),{renderingContext:o,methods:{devTools:{onClose:()=>r(!1)}},enableLogging:!0,sizeWidth:!0,loadingComponent:T.default.createElement($,{isLoading:!0})}))))}function ce(e){let t="cardsApp",o=(0,d.useMemo)(()=>({entryPoint:t}),[t]);return d.default.createElement(f,m(a({},e),{renderingContext:o}))}var we=ce;function Me(r){var i=r,{cardholder:e,onDone:t,onCancel:o}=i,n=D(i,["cardholder","onDone","onCancel"]);let s="createCard",c=(0,d.useMemo)(()=>({entryPoint:s,cardholder:e}),[e]);return d.default.createElement(f,m(a({},n),{renderingContext:c,methods:{createCard:{onDone:t,onCancel:o}}}))}function Ae(r){var i=r,{transactionId:e,onDone:t,onCancel:o}=i,n=D(i,["transactionId","onDone","onCancel"]);let s="createDispute",c=(0,d.useMemo)(()=>({entryPoint:s,transactionId:e}),[e]);return d.default.createElement(f,m(a({},n),{renderingContext:c,methods:{createDispute:{onDone:t,onCancel:o}}}))}function Se(e){let t="billPayApp",o=(0,d.useMemo)(()=>({entryPoint:t}),[t]);return d.default.createElement(f,m(a({},e),{renderingContext:o}))}function ze(e){let i=e,{onCardCanceled:t}=i,o=D(i,["onCardCanceled"]),n="cardDetails",r=(0,d.useMemo)(()=>({entryPoint:n,cardId:e.cardId,cardOnly:e.cardOnly,hideAddress:e.hideAddress}),[n,e.cardId,e.cardOnly]);return d.default.createElement(f,m(a({},o),{renderingContext:r,methods:{cardDetails:{onCardCanceled:t!=null?t:()=>{}}}}))}function Fe(e){let t="accountDetails",o=(0,d.useMemo)(()=>({entryPoint:t}),[t]);return d.default.createElement(f,m(a({},e),{renderingContext:o}))}function Re(e){let t="accountActions",o=(0,d.useMemo)(()=>({entryPoint:t}),[t]);return d.default.createElement(f,m(a({},e),{renderingContext:o}))}function He(e){let t="insightsDashboard",o=(0,d.useMemo)(()=>({entryPoint:t}),[t]);return d.default.createElement(f,m(a({},e),{renderingContext:o}))}function Be(e){let t="insightsWidget",{widget:o,hideTitle:n,height:r,width:i}=e,s=(0,d.useMemo)(()=>({entryPoint:t,widget:o,hideTitle:n,height:r,width:i}),[t,o,n,r,i]);return d.default.createElement(f,m(a({},e),{renderingContext:s}))}function Ue(r){var i=r,{onDone:e,entryPoint:t,exitPoint:o}=i,n=D(i,["onDone","entryPoint","exitPoint"]);let s="onboarding",c=(0,d.useMemo)(()=>({entryPoint:s,onboardingEntryPoint:t,onboardingExitPoint:o}),[s,t,o]);return d.default.createElement(f,m(a({},n),{renderingContext:c,methods:{onboarding:{onDone:e}}}))}function _e(o){var n=o,{onDone:e}=n,t=D(n,["onDone"]);let r="makePayment",i=(0,d.useMemo)(()=>({entryPoint:r}),[r]);return d.default.createElement(f,m(a({},t),{renderingContext:i,methods:{makePayment:{onDone:e}}}))}0&&(module.exports={AccountActions,AccountDetails,App,BillPayApp,CapitalOsAuthenticationProvider,CardDetails,CardsApp,DevTools,DisputeTransaction,InsightsDashboard,InsightsWidget,IssueCard,MakePayment,Onboarding});
10
+ `),L.default.createElement(ve,null)):L.default.createElement("button",{id:"dev-tools-button",onClick:e,type:"button",style:s,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),onFocus:()=>i(!0),onBlur:()=>i(!1)},L.default.createElement(ve,null))}var $e={panel:{position:"fixed",bottom:"20px",left:"20px",zIndex:50}};function ke(e){let t="devTools",n=(0,w.useMemo)(()=>({entryPoint:t}),[t]),[o,r]=(0,be.useState)(!1);return w.default.createElement("aside",{"aria-label":"CapitalOS dev tools"},!o&&w.default.createElement(oe,{onClick:()=>r(!o)}),o&&w.default.createElement("div",{style:$e.panel},w.default.createElement(g,u(d({},e),{renderingContext:n,methods:{devTools:{onClose:()=>r(!1)}},enableLogging:!0,sizeWidth:!0,loadingComponent:w.default.createElement(oe,{isLoading:!0})}))))}function Te(e){let t="cardsApp",n=(0,c.useMemo)(()=>({entryPoint:t}),[t]);return c.default.createElement(g,u(d({},e),{renderingContext:n}))}var Ke=Te;function Ve(r){var i=r,{cardholder:e,onDone:t,onCancel:n}=i,o=k(i,["cardholder","onDone","onCancel"]);let s="createCard",a=(0,c.useMemo)(()=>({entryPoint:s,cardholder:e}),[e]);return c.default.createElement(g,u(d({},o),{renderingContext:a,methods:{createCard:{onDone:t,onCancel:n}}}))}function Je(r){var i=r,{transactionId:e,onDone:t,onCancel:n}=i,o=k(i,["transactionId","onDone","onCancel"]);let s="createDispute",a=(0,c.useMemo)(()=>({entryPoint:s,transactionId:e}),[e]);return c.default.createElement(g,u(d({},o),{renderingContext:a,methods:{createDispute:{onDone:t,onCancel:n}}}))}function Xe(e){let t="billPayApp",n=(0,c.useMemo)(()=>({entryPoint:t}),[t]);return c.default.createElement(g,u(d({},e),{renderingContext:n}))}function Ze(e){let i=e,{onCardCanceled:t}=i,n=k(i,["onCardCanceled"]),o="cardDetails",r=(0,c.useMemo)(()=>({entryPoint:o,cardId:e.cardId,cardOnly:e.cardOnly,hideAddress:e.hideAddress}),[o,e.cardId,e.cardOnly]);return c.default.createElement(g,u(d({},n),{renderingContext:r,methods:{cardDetails:{onCardCanceled:t!=null?t:()=>{}}}}))}function Ge(e){let t="accountDetails",n=(0,c.useMemo)(()=>({entryPoint:t}),[t]);return c.default.createElement(g,u(d({},e),{renderingContext:n}))}function Qe(e){let t="accountActions",n=(0,c.useMemo)(()=>({entryPoint:t}),[t]);return c.default.createElement(g,u(d({},e),{renderingContext:n}))}function Ye(e){let t="insightsDashboard",n=(0,c.useMemo)(()=>({entryPoint:t}),[t]);return c.default.createElement(g,u(d({},e),{renderingContext:n}))}function et(e){let t="insightsWidget",{widget:n,hideTitle:o,height:r,width:i}=e,s=(0,c.useMemo)(()=>({entryPoint:t,widget:n,hideTitle:o,height:r,width:i}),[t,n,o,r,i]);return c.default.createElement(g,u(d({},e),{renderingContext:s}))}function tt(r){var i=r,{onDone:e,entryPoint:t,exitPoint:n}=i,o=k(i,["onDone","entryPoint","exitPoint"]);let s="onboarding",a=(0,c.useMemo)(()=>({entryPoint:s,onboardingEntryPoint:t,onboardingExitPoint:n}),[s,t,n]);return c.default.createElement(g,u(d({},o),{renderingContext:a,methods:{onboarding:{onDone:e}}}))}function nt(n){var o=n,{onDone:e}=o,t=k(o,["onDone"]);let r="makePayment",i=(0,c.useMemo)(()=>({entryPoint:r}),[r]);return c.default.createElement(g,u(d({},t),{renderingContext:i,methods:{makePayment:{onDone:e}}}))}function ot(o){var r=o,{onDone:e,onCancel:t}=r,n=k(r,["onDone","onCancel"]);let i="contactSupport",s=(0,c.useMemo)(()=>({entryPoint:i}),[i]);return c.default.createElement(g,u(d({},n),{renderingContext:s,methods:{contactSupport:{onDone:e,onCancel:t}}}))}function rt(n){var o=n,{onDone:e}=o,t=k(o,["onDone"]);let r="statements",i=(0,c.useMemo)(()=>({entryPoint:r}),[r]);return c.default.createElement(g,u(d({},t),{renderingContext:i,methods:{statements:{onDone:e}}}))}function it(n){var o=n,{onDone:e}=o,t=k(o,["onDone"]);let r="legalDocuments",i=(0,c.useMemo)(()=>({entryPoint:r}),[r]);return c.default.createElement(g,u(d({},t),{renderingContext:i,methods:{legalDocuments:{onDone:e}}}))}function st(r){var i=r,{cardId:e,onDone:t,onClose:n}=i,o=k(i,["cardId","onDone","onClose"]);let s="replaceCard",a=(0,c.useMemo)(()=>({entryPoint:s,cardId:e}),[e]);return c.default.createElement(g,u(d({},o),{renderingContext:a,methods:{replaceCard:{onDone:t,onClose:n}}}))}function at(r){var i=r,{cardId:e,onDone:t,onClose:n}=i,o=k(i,["cardId","onDone","onClose"]);let s="terminateCard",a=(0,c.useMemo)(()=>({entryPoint:s,cardId:e}),[e]);return c.default.createElement(g,u(d({},o),{renderingContext:a,methods:{terminateCard:{onDone:t,onClose:n}}}))}function ct(){let e=(0,c.useContext)(ne);if(!e)throw new h({message:"useActions must be used within a CapitalOsAuthenticationProvider",code:T.internal_error});let{childFunctions:t,isLoading:n}=e;return{actions:t,isLoading:n}}0&&(module.exports={AccountActions,AccountDetails,App,BillPayApp,CapitalOsAuthenticationProvider,CardDetails,CardsApp,ContactSupport,DevTools,DisputeTransaction,InsightsDashboard,InsightsWidget,IssueCard,LegalDocuments,MakePayment,Onboarding,ReplaceCard,Statements,TerminateCard,useActions});
11
11
  //# sourceMappingURL=index.js.map