import { CachePolicy, ListOutput } from '@sudoplatform/sudo-common'; import { SudoPlatformSignInCallback } from '@sudoplatform/sudo-user'; import { APIResult } from './typings/apiResult'; import { CreateKeysIfAbsentResult } from './typings/createKeysIfAbsentResult'; import { DateRange } from './typings/dateRange'; import { FundingSource, FundingSourceChangeSubscriber, FundingSourceClientConfiguration, FundingSourceFilterInput, FundingSourceType, ProvisionalFundingSource, ProvisionalFundingSourceFilterInput } from './typings/fundingSource'; import { ListProvisionalCardsResults, ListTransactionsResults, ListVirtualCardsResults } from './typings/listOperationResult'; import { Metadata } from './typings/metadata'; import { ProvisionalVirtualCard } from './typings/provisionalCard'; import { SortOrder } from './typings/sortOrder'; import { SudoVirtualCardsClientOptions } from './typings/sudoVirtualCardsClientOptions'; import { Transaction, TransactionType } from './typings/transaction'; import { BillingAddress, VirtualCard, VirtualCardFilterInput, VirtualCardSealedAttributes } from './typings/virtualCard'; import { VirtualCardsConfig } from './typings/virtualCardsConfig'; /** * Input for {@link SudoVirtualCardsClient#setupFundingSource}. * * @property {string} currency The ISO 4217 currency code that is being used for the setup. * @property {FundingSourceType} type The type of the funding source being setup. * @property {string} applicationName * The name of the client application. Must be shared with the service for * configuration purposes. * @property {string[]} supportedProviders * Names of providers supported by the client. Will default to the default * provider for the funding source type depending on configuration of the * service. * @property {string} language * Some funding source types require presentation of end-user language * specific agreements. This property allows the client application * to specify the user's preferred language. If such presentation is * required and has no translation in the requested language or no * preferred language is specified, the default translation will be * presented. The default is a property of service instance * configuration. The value is an RFC 5646 language tag e.g. en-US. */ export interface SetupFundingSourceInput { currency: string; type: FundingSourceType; applicationName: string; supportedProviders?: string[]; language?: string; } /** * Input for the completion data of {@link SudoVirtualCardsClient#completeFundingSource}. * * @property {string} provider Provider used to save the funding source information. * @property {FundingSourceType.CreditCard} type * Funding source provider type. Must be CreditCard if provided. * Optional for backwards compatibility. * @property {string} paymentMethod Identifier of the Payment Method used. */ export interface CompleteFundingSourceStripeCardCompletionDataInput { provider: 'stripe'; type?: FundingSourceType.CreditCard; paymentMethod: string; } export type CompleteFundingSourceCompletionDataInput = CompleteFundingSourceStripeCardCompletionDataInput; /** * Input for {@link SudoVirtualCardsClient.completeFundingSource}. * * @property {string} id Identifier of the provisional funding source to be completed and provisioned. * @property {string} completionData JSON string of the completion data to be passed back to the service. * @property {boolean} updateCardFundingSource flag to indicate whether to update inactive card funding sources * with a new funding source when a funding source is created. */ export interface CompleteFundingSourceInput { id: string; completionData: CompleteFundingSourceCompletionDataInput; updateCardFundingSource?: boolean; } /** * Input for {@link SudoVirtualCardsClient.getFundingSource}. * * @property {string} id The identifier of the funding source to be retrieved. * @property {CachePolicy} cachePolicy Determines how the funding source will be fetched. */ export interface GetFundingSourceInput { id: string; cachePolicy?: CachePolicy; } /** * Input for {@link SudoVirtualCardsClient.listFundingSources}. * * @property {FundingSourceFilterInput} filter The filter to be applied to the list of * funding sources to return. * @property {SortOrder} sortOrder Order in which records are returned (based on date/time at which * the funding source was updated). The default order is descending, ie, most recently updated first. * @property {CachePolicy} cachePolicy Determines how the funding sources will be fetched. * @property {number} limit Maximum number of items to return. Will be defaulted if omitted. * @property {string} nextToken Paginated next token. */ export interface ListFundingSourcesInput { filter?: FundingSourceFilterInput; sortOrder?: SortOrder; cachePolicy?: CachePolicy; limit?: number; nextToken?: string; } /** * Input for {@link SudoVirtualCardsClient.listProvisionalFundingSources}. * * @property {ProvisionalFundingSourceFilterInput} filter The filter to be applied to the list of * provisional funding sources to return. * @property {SortOrder} sortOrder Order in which records are returned (based on date/time at which * the provisional funding source was updated). The default order is descending, ie, most recently * updated first. * @property {CachePolicy} cachePolicy Determines how the funding sources will be fetched. * @property {number} limit Maximum number of items to return. Will be defaulted if omitted. * @property {string} nextToken Paginated next token. */ export interface ListProvisionalFundingSourcesInput { filter?: ProvisionalFundingSourceFilterInput; sortOrder?: SortOrder; cachePolicy?: CachePolicy; limit?: number; nextToken?: string; } /** * Input for {@link ProvisionVirtualCardInput} billingAddress. * * @property {string} addressLine1 First line of the billing address. * @property {string} addressLine2 Optional - Second line of the billing address. * @property {string} city City of the billing address. * @property {string} state State of the billing address. * @property {string} postalCode Postal Code of the billing address. * @property {string} country Country of the billing address. */ export interface ProvisionVirtualCardBillingAddressInput { addressLine1: string; addressLine2?: string; city: string; state: string; postalCode: string; country: string; } /** * Input for {@link SudoVirtualCardsClient.provisionVirtualCard}. * * @property {string[]} ownershipProofs Proof of sudo ownership for provisioning cards. The ownership proof must * contain an audience of "sudoplatform.virtual-cards.virtual-card". * @property {string} fundingSourceId Identifier of the funding source backing the provisioned card. * @property {string} cardHolder Name to appear on the card. * @property {string} currency ISO Currency code to provision the card with. * @property {ProvisionVirtualCardBillingAddressInput} billingAddress Optional - Billing address of the card. * @property {string} clientRefId Optional - Identifier of the client. * @property {JSONValue} metadata Client side sealed arbitrary metadata object */ export interface ProvisionVirtualCardInput { ownershipProofs: string[]; fundingSourceId: string; cardHolder: string; currency: string; billingAddress?: ProvisionVirtualCardBillingAddressInput; clientRefId?: string; metadata?: Metadata; /** @deprecated Specify as an alias property in metadata instead */ alias?: string; } /** * Input for {@link SudoVirtualCardsClient.updateVirtualCard}. * * To leave a property unchanged, leave it undefined. * To remove a property, set it to null. * To update a property, set it to the new value. * * @property {string} id Identifier of the card to update. * @property {number} expectedCardVersion Version of card to update. If specified, version must match existing version of card. * @property {string} cardHolder Updated card holder. Leave as existing to remain unchanged. * @property {string} billingAddress Updated billing address. To remove, set to undefined. * @property {JSONValue} metadata Client side sealed arbitrary metadata object */ export interface UpdateVirtualCardInput { id: string; expectedCardVersion?: number; cardHolder?: string; billingAddress?: BillingAddress | null; metadata?: Metadata | null; /** @deprecated Use an alias property in metadata instead */ alias?: string | null; } /** * Input for {@link SudoVirtualCardsClient.cancelVirtualCard} * * @property {string} id Identifier of the card to cancel. */ export interface CancelVirtualCardInput { id: string; } /** * Input for {@link SudoVirtualCardsClient.getProvisionalCard}. * * @property {string} id Identifier of the provisional card to get. * @property {CachePolicy} cachePolicy Cache Policy to use to access provisional card. */ export interface GetProvisionalCardInput { id: string; cachePolicy?: CachePolicy; } /** * Input for {@link SudoVirtualCardsClient.listProvisionalCards}. * * @property {CachePolicy} cachePolicy Cache Policy to use to access provisional cards. * @property {number} limit Maximum number of cards to return. * @property {string} nextToken Paginated next token. */ export interface ListProvisionalCardsInput { cachePolicy?: CachePolicy; limit?: number; nextToken?: string; } /** * Input for {@link SudoVirtualCardsClient.getVirtualCard}. * * @property {string} id Identifier of the virtual card to get. * @property {CachePolicy} cachePolicy Cache Policy to use to access virtual card. */ export interface GetVirtualCardInput { id: string; cachePolicy?: CachePolicy; } /** * Input for {@link SudoVirtualCardsClient.listVirtualCards}. * * @property {VirtualCardFilterInput} filter The filter to be applied to the list of * virtual cards to return. * @property {SortOrder} sortOrder Order in which records are returned (based on date/time at which * the virtual card was updated). The default order is descending, ie, most recently updated first. * @property {CachePolicy} cachePolicy Cache Policy to use to access virtual cards. * @property {number} limit Maximum number of cards to return. * @property {string} nextToken Paginated next token. */ export interface ListVirtualCardsInput { filter?: VirtualCardFilterInput; sortOrder?: SortOrder; cachePolicy?: CachePolicy; limit?: number; nextToken?: string; } /** * Input for {@link SudoVirtualCardsClient.getTransaction}. * * @property {string} id Identifier of the transaction to get. * @property {CachePolicy} cachePolicy Cache Policy to use to access a transaction. */ export interface GetTransactionInput { id: string; cachePolicy?: CachePolicy; } /** * Input for {@link SudoVirtualCardsClient.listTransactions} * * @property {CachePolicy} cachePolicy Cache Policy to use to access transactions. * @property {number} limit Maximum number of transactions to return. * @property {string} nextToken Paginated next token. * @property {DateRange} dateRange * Inclusive start and end dates between which to search. Default: no date range * @property {SortOrder} sortOrder * Sort order or results. Default: SortOrder.Asc */ export interface ListTransactionsInput { cachePolicy?: CachePolicy; limit?: number; nextToken?: string; dateRange?: DateRange; sortOrder?: SortOrder; } /** * Input for {@link SudoVirtualCardsClient.listTransactionsByCardId} * * @property {string} cardId Identifier of the card to list for related transactions. * @property {CachePolicy} cachePolicy Cache Policy to use to access transactions. * @property {number} limit Maximum number of transactions to return. * @property {string} nextToken Paginated next token. * @property {DateRange} dateRange * Inclusive start and end dates between which to search. Default: no date range * @property {SortOrder} sortOrder * Sort order or results. Default: SortOrder.Asc */ export interface ListTransactionsByCardIdInput { cardId: string; cachePolicy?: CachePolicy; limit?: number; nextToken?: string; dateRange?: DateRange; sortOrder?: SortOrder; } /** * Input for {@link SudoVirtualCardsClient.listTransactionsByCardIdAndType} * * @property {string} cardId Identifier of the card to list for related transactions. * @property {TransactionType} transactionType The type of transactions to retrieve. * @property {CachePolicy} cachePolicy Cache Policy to use to access transactions. * @property {number} limit Maximum number of transactions to return. * @property {string} nextToken Paginated next token. */ export interface ListTransactionsByCardIdAndTypeInput { cardId: string; transactionType: TransactionType; cachePolicy?: CachePolicy; limit?: number; nextToken?: string; } /** * Sudo Platform Virtual Cards client API * * All methods should be expected to be able to throw the following * errors defined in `@sudoplatform/sudo-common`: * * @throws NotSignedInError * User not signed in. Sign in before performing the operation. * @throws AccountLockedError * Account has been locked. Contact support. * @throws ServiceError * Transient error at the service. Try the operation again */ export interface SudoVirtualCardsClient { /** * Create key pair and secret key for use by the Virtual Cards Client if * they have not already been created. * * The key pair is used to register a public key with the service for the * encryption of virtual card and transaction details. * * The secret key is used for client side encryption of user specific * card metadata. * * @returns {CreateKeysIfAbsentResult} */ createKeysIfAbsent(): Promise; /** * @deprecated Use `getVirtualCardsConfig` instead to retrieve the FundingSourceClientConfiguration. * * Get the funding source client configuration. * * @returns {FundingSourceClientConfiguration} The configuration of the client funding source data. */ getFundingSourceClientConfiguration(): Promise; /** * Initiate provisioning of a new funding source. * * @param {SetupFundingSourceInput} input Parameters used to setup the provisional funding source. * * @returns {ProvisionalFundingSource} The provisional funding source. * * @throws InsufficientEntitlementsError * User has insufficient entitlements to setup a new funding source. * @throws {@link VelocityExceededError} * Configured maximum rate of attempts to add a funding source has * been exceeded or too many failed attempts have recently been made. * Wait before retrying. */ setupFundingSource(input: SetupFundingSourceInput): Promise; /** * Complete provisioning of a funding source. * * @param {CompleteFundingSourceInput} input Parameters used to complete the funding source. * * @returns {FundingSource} The funding source to be provisioned. * * @throws {@link DuplicateFundingSourceError} * User already has an active funding source matching the funding * source being created. * @throws {@link FundingSourceCompletionDataInvalidError} * Completion data provided does not match provisional funding * source specified. * @throws {@link IdentityVerificationNotVerifiedError} * Identity information associated with funding source does not * sufficiently match identity information provided during identity * verification. * @throws {@link ProvisionalFundingSourceNotFoundError} * No provisional funding source with the ID specified could be found. * @throws {@link UnacceptableFundingSourceError} * The funding source provided is not acceptable for use to fund virtual * card transactions. * @throws {@link FundingSourceRequiresUserInteractionError} * The funding source requires additional user interaction for provisioning * can complete. The error's provisioningData property contains * provider specific data to be used in this process. */ completeFundingSource(input: CompleteFundingSourceInput): Promise; /** * Subscribe to changes to funding sources * * @param {string} id unique identifier to differentiate subscriptions; note that specifying a duplicate subscription * id will replace the previous subscription. * @param {FundingSourceChangeSubscriber} subscriber implementation of callback to be invoked when funding source change occurs * * @returns {void} */ subscribeToFundingSourceChanges(id: string, subscriber: FundingSourceChangeSubscriber): Promise; /** * Unsubscribe from changes to funding sources * * @param {string} id unique identifier to differentiate subscription * * @returns {void} **/ unsubscribeFromFundingSourceChanges(id: string): void; /** * Get a funding source identified by id. * * @param {GetFundingSourceInput} input Parameters used to retrieve a funding source. * * @returns {FundingSource | undefined} The funding source identified by id or undefined if the funding source * cannot be found. * * @throws {@link FundingSourceNotFoundError} * No funding source matching the specified ID could be found. */ getFundingSource(input: GetFundingSourceInput): Promise; /** * Get a list of all created funding sources for the signed in user. * * @param {ListFundingSourcesInput} input Parameters used to retrieve a list of created funding sources. * @returns {ListOutput} An array of funding sources or an empty array if no matching funding sources * can be found. */ listFundingSources(input?: ListFundingSourcesInput): Promise>; /** * Cancel a single funding source identified by id. * * @param {string} id The identifier of the funding source to cancel. * @returns {FundingSource} The funding source that was cancelled. * * @throws {@link FundingSourceNotFoundError} * No funding source matching the specified ID could be found. */ cancelFundingSource(id: string): Promise; /** * Cancel a single provisional funding source identified by id. * * @param {string} id The identifier of the provisional funding source to cancel. * @returns {ProvisionalFundingSource} The provisional funding source that was cancelled and is in a failed state. * * @throws {@link FundingSourceNotFoundError} * No provisional funding source matching the specified ID could be found. */ cancelProvisionalFundingSource(id: string): Promise; /** * Get a list of provisional funding sources. If no provisional funding * sources can be found, an empty list will be returned. * * @param {ListProvisionalFundingSourcesInput} input Parameters used to list the * provisional funding sources. */ listProvisionalFundingSources(input: ListProvisionalFundingSourcesInput): Promise>; /** * Provision a virtual card. * * @param {ProvisionVirtualCardInput} input Parameters used to provision a virtual card. * * @returns {ProvisionalVirtualCard} The card that is being provisioned. Please poll * the card via the list methods to access the card. * * @throws {@link FundingSourceNotFoundError} * No funding source matching the specified ID could be found. * @throws {@link FundingSourceNotActiveError} * The funding source matching the specified ID is not active. * @throws InsufficientEntitlementsError * User has insufficient entitlements to setup a new virtual card. * @throws {@link VelocityExceededError} * Configured maximum rate of attempts to add a virtual card has * been exceeded. Wait before retrying. */ provisionVirtualCard(input: ProvisionVirtualCardInput): Promise; /** * Update a virtual card. * @param input Parameters used to update a virtual card. * * @returns {VirtualCard} The virtual card that was updated. * * @throws {@link CardNotFoundError} * No virtual card matching the ID specified could be found * @throws {@link CardStateError} * Card not in ISSUED state. It must be in ISSUED state in order * to update. */ updateVirtualCard(input: UpdateVirtualCardInput): Promise>; /** * Cancel a virtual card. * @param input Parameters used to cancel a virtual card. * * @returns {string} The identifier of the card that was just cancelled. * * @throws {@link CardNotFoundError} * No virtual card matching the ID specified could be found */ cancelVirtualCard(input: CancelVirtualCardInput): Promise>; /** * Get a provisional card. * @param input Parameters used to get a provisional card. * * @returns {ProvisionalVirtualCard | undefined} The card that is being queried, or undefined if not found. */ getProvisionalCard(input: GetProvisionalCardInput): Promise; /** * List provisional cards. * @param input Parameters used to list provisional cards. * * @returns {ListProvisionalCardsResults} Result of the provisional card list. */ listProvisionalCards(input?: ListProvisionalCardsInput): Promise; /** * Get a virtual card. * @param input Parameters used to get a virtual card. * * @returns {ProvisionalVirtualCard | undefined} The card that is being queried, or undefined if not found. */ getVirtualCard(input: GetVirtualCardInput): Promise; /** * List virtual cards. * @param input Parameters used to list virtual cards. * * @returns {ListProvisionalCardsResults} Result of the virtual card list. */ listVirtualCards(input?: ListVirtualCardsInput): Promise; /** * Get a transaction. * @param input Parameters used to get a transaction. * * @returns {Transaction | undefined} The transaction that is being queried, or undefined if not found. */ getTransaction(input: GetTransactionInput): Promise; /** * List all of a user's transactions. * * @param input Parameters used for listing transactions for a user. * * @returns {ListTransactionsResults} Results of the transaction list. */ listTransactions(input: ListTransactionsInput): Promise; /** * List transactions for a virtual card. * * @param input Parameters used for listing a virtual card's transactions. * * @returns {ListTransactionsResults} Results of the transaction list. */ listTransactionsByCardId(input: ListTransactionsByCardIdInput): Promise; /** * List transactions for a virtual card and transaction type. * * @param input Parameters used for listing a virtual card's transactions. * * @returns {ListTransactionsResults} Results of the transaction list. */ listTransactionsByCardIdAndType(input: ListTransactionsByCardIdAndTypeInput): Promise; /** * Get the configuration data for the virtual cards service. * * @returns {VirtualCardsConfig} The configuration data for the virtual cards service. */ getVirtualCardsConfig(): Promise; exportKeys(): Promise; /** * Imports cryptographic keys from a key archive. * * @param archiveData Key archive data to import the keys from. */ importKeys(archiveData: ArrayBuffer): Promise; /** * Sets an optional callback to handle sign-in when operations are attempted * while not signed in. * * When set, all operations (exception subscriptions and initialization/reset) will * check sign-in status before performing their normal behavior. If the client is * not signed in, the callback will be invoked to allow the host app to perform * sign-in. Once the callback completes, then the client will attempt the original * operation that triggered the callback. * If the callback throws an error, then the error will be propagated to the caller * and the original operation will not be attempted. * To clear the callback, call this method with no arguments or undefined. */ setSignInCallback(callback?: SudoPlatformSignInCallback): void; /** * Removes any cached data maintained by this client. */ reset(): Promise; } export declare class DefaultSudoVirtualCardsClient implements SudoVirtualCardsClient { private readonly apiClient; private readonly configurationDataService; private readonly fundingSourceService; private readonly sudoUserService; private readonly virtualCardService; private readonly transactionService; private readonly keyService; private readonly deviceKeyWorker; private readonly transactionWorker; private readonly keyManager; private readonly cryptoProvider; private readonly sudoUserClient; private readonly signInGuard; private readonly log; private readonly serialise; constructor(opts: SudoVirtualCardsClientOptions); setSignInCallback(callback?: SudoPlatformSignInCallback): void; /** * Create key pair and secret key for use by the Virtual Cards Client if * they have not already been created. * * The key pair is used to register a public key with the service for the * encryption of virtual card and transaction details. * * The secret key is used for client side encryption of user specific * card metadata. */ createKeysIfAbsent(): Promise; getFundingSourceClientConfiguration(): Promise; setupFundingSource(input: SetupFundingSourceInput): Promise; completeFundingSource(input: CompleteFundingSourceInput): Promise; subscribeToFundingSourceChanges(id: string, subscriber: FundingSourceChangeSubscriber): Promise; unsubscribeFromFundingSourceChanges(id: string): void; getFundingSource({ id, cachePolicy, }: GetFundingSourceInput): Promise; listFundingSources(input?: ListFundingSourcesInput): Promise>; cancelFundingSource(id: string): Promise; cancelProvisionalFundingSource(id: string): Promise; listProvisionalFundingSources(input: ListProvisionalFundingSourcesInput): Promise>; provisionVirtualCard(input: ProvisionVirtualCardInput): Promise; updateVirtualCard(input: UpdateVirtualCardInput): Promise>; cancelVirtualCard(input: CancelVirtualCardInput): Promise>; getProvisionalCard({ id, cachePolicy, }: GetProvisionalCardInput): Promise; listProvisionalCards(input: ListProvisionalCardsInput): Promise; getVirtualCard({ id, cachePolicy, }: GetVirtualCardInput): Promise; listVirtualCards(input: ListVirtualCardsInput): Promise; getTransaction(input: GetTransactionInput): Promise; listTransactions(input: ListTransactionsInput): Promise; listTransactionsByCardId(input: ListTransactionsByCardIdInput): Promise; listTransactionsByCardIdAndType(input: ListTransactionsByCardIdAndTypeInput): Promise; getVirtualCardsConfig(): Promise; exportKeys(): Promise; importKeys(archiveData: ArrayBuffer): Promise; reset(): Promise; /** * Checks if user is signed in and invokes callback if needed. * Only performs check if callback is configured. * * Throws: Any error thrown by the sign-in callback */ private ensureSignedIn; }