UNPKG

zumokit

Version:

ZumoKit is a Wallet as a Service SDK

236 lines (235 loc) 11.9 kB
import { Decimal } from 'decimal.js'; import { CurrencyCode, Network, AccountType, Address, CardType, CardStatus, KbaAnswer, CustodyType } from './interfaces'; import { Wallet } from './Wallet'; import { Account, AccountFiatProperties, AccountDataSnapshot, ComposedTransaction, ComposedExchange, Transaction, Exchange } from './models'; /** * User instance, obtained via {@link ZumoKit.signIn} method, provides methods for managing user wallet and accounts. * <p> * Refer to * <a href="https://developers.zumo.money/docs/guides/manage-user-wallet">Manage User Wallet</a>, * <a href="https://developers.zumo.money/docs/guides/create-fiat-account">Create Fiat Account</a>, * <a href="https://developers.zumo.money/docs/guides/view-user-accounts">View User Accounts</a> and * <a href="https://developers.zumo.money/docs/guides/get-account-data">Get Account Data</a> * guides for usage details. */ export declare class User { private zumoCoreModule; private userImpl; private accountDataListeners; private accountDataListenersImpl; /** User identifier. */ id: string; /** User integrator identifier. */ integratorId: string; /** Indicator if user has wallet. */ hasWallet: boolean; /** User accounts. */ accounts: Array<Account>; /** @internal */ constructor(zumoCoreModule: any, userImpl: any); /** * Create user wallet seeded by provided mnemonic and encrypted with user's password. * <p> * Mnemonic can be generated by {@link Utils.generateMnemonic} utility method. * @param mnemonic mnemonic seed phrase * @param password user provided password */ createWallet(mnemonic: string, password: string): Promise<Wallet>; /** * Recover user wallet with mnemonic seed phrase corresponding to user's wallet. * This can be used if user forgets his password or wants to change his wallet password. * @param mnemonic mnemonic seed phrase corresponding to user's wallet * @param password user provided password */ recoverWallet(mnemonic: string, password: string): Promise<Wallet>; /** * Unlock user wallet with user's password. * @param password user provided password */ unlockWallet(password: string): Promise<Wallet>; /** * Reveal mnemonic seed phrase used to seed user wallet. * @param password user provided password */ revealMnemonic(password: string): Promise<string>; /** * Check if mnemonic seed phrase corresponds to user's wallet. * This is useful for validating seed phrase before trying to recover wallet. * @param mnemonic mnemonic seed phrase */ isRecoveryMnemonic(mnemonic: string): boolean; /** * Get account in specific currency, on specific network, with specific type. * @param currencyCode currency code, e.g. 'BTC', 'ETH' or 'GBP' * @param network network type, e.g. 'MAINNET', 'TESTNET' or 'RINKEBY' * @param type account type, e.g. 'STANDARD', 'COMPATIBILITY' or 'SEGWIT' * @param custodyType custody type, e.g. 'CUSTODY' or 'NON-CUSTODY' */ getAccount(currencyCode: CurrencyCode, network: Network, type: AccountType, custodyType: CustodyType): Account | null; /** * Check if user is a registered fiat customer. */ isFiatCustomer(): boolean; /** * Make user fiat customer by providing user's personal details. * @param firstName first name * @param middleName middle name or null * @param lastName last name * @param dateOfBirth date of birth in ISO 8601 format, e.g '2020-08-12' * @param email email * @param phone phone number * @param address home address */ makeFiatCustomer(firstName: string, middleName: string | null, lastName: string, dateOfBirth: string, email: string, phone: string, address: Address): Promise<void>; /** * Create custody or fiat account for specified currency. When creating a fiat account, * user must already be fiat customer. * @param currencyCode country code in ISO 4217 format, e.g. 'GBP' */ createAccount(currencyCode: CurrencyCode): Promise<Account>; /** * Get nominated account details for specified account if it exists. * Refer to * <a href="https://developers.zumo.money/docs/guides/send-transactions#bitcoin">Create Fiat Account</a> * for explanation about nominated account. * @param accountId {@link Account Account} identifier */ getNominatedAccountFiatProperties(accountId: string): Promise<AccountFiatProperties | null>; /** * Fetch Strong Customer Authentication (SCA) config. */ fetchAuthenticationConfig(): Promise<void>; /** * Create card for a fiat account. * <p> * At least one Knowledge-Based Authentication (KBA) answers should be defined, * answers are limited to 256 characters and cannot be null or empty and only * one answer per question type should be provided. * @param fiatAccountId fiat {@link Account account} identifier * @param cardType 'VIRTUAL' or 'PHYSICAL' * @param mobileNumber card holder mobile number, starting with a '+', followed by the country code and then the mobile number, or null * @param knowledgeBase list of KBA answers */ createCard(fiatAccountId: string, cardType: CardType, mobileNumber: string, knowledgeBase: Array<KbaAnswer>): Promise<void>; /** * Set card status to 'ACTIVE', 'BLOCKED' or 'CANCELLED'. * - To block card, set card status to 'BLOCKED'. * - To activate a physical card, set card status to 'ACTIVE' and provide PAN and CVC2 fields. * - To cancel a card, set card status to 'CANCELLED'. * - To unblock a card, set card status to 'ACTIVE.'. * @param cardId {@link Card card} identifier * @param cardStatus new card status * @param pan PAN when activating a physical card, null otherwise (defaults to null) * @param cvv2 CVV2 when activating a physical card, null otherwise (defaults to null) */ setCardStatus(cardId: string, cardStatus: CardStatus, pan?: string | null, cvv2?: string | null): Promise<void>; /** * Reveals sensitive card details. * @param cardId card identifier */ revealCardDetails(cardId: string): Promise<void>; /** * Reveal card PIN. * @param cardId {@link Card card} identifier */ revealPin(cardId: string): Promise<void>; /** * Unblock card PIN. * @param cardId {@link Card card} identifier */ unblockPin(cardId: string): Promise<void>; /** * Add KBA answers to a card without SCA. * <p> * This endpoint is used to set Knowledge-Based Authentication (KBA) answers to * a card without Strong Customer Authentication (SCA). Once it is set SCA flag * on corresponding card is set to true. * <p> * At least one answer should be defined, answers are limited to 256 characters and * cannot be null or empty and only one answer per question type should be provided. * * @param cardId card id * @param knowledgeBase list of KBA answers */ setAuthentication(cardId: string, knowledgeBase: Array<KbaAnswer>): Promise<void>; /** * Listen to all account data changes. * * @param listener interface to listen to user changes */ addAccountDataListener(listener: (snapshots: Array<AccountDataSnapshot>) => void): void; /** * Remove listener to state changes. * * @param listener interface to listen to state changes */ removeAccountDataListener(listener: (snapshots: Array<AccountDataSnapshot>) => void): void; /** * Compose transaction between custody or fiat accounts in Zumo ecosystem. * Refer to <a href="https://developers.zumo.money/docs/guides/send-transactions#internal-transaction">Send Transactions</a> * guide for usage details. * * @param fromAccountId custody or fiat {@link Account Account} identifier * @param toAccountId custody or fiat {@link Account Account} identifier * @param amount amount in source account currency * @param sendMax send maximum possible funds to destination (defaults to false) */ composeTransaction(fromAccountId: string, toAccountId: string, amount: Decimal | null, sendMax?: boolean): Promise<ComposedTransaction>; /** * Compose custody withdraw transaction from custody account. * Refer to <a href="https://developers.zumo.money/docs/guides/send-transactions#custody-withdraw-transaction">Send Transactions</a> * guide for usage details. * * @param fromAccountId custody or fiat {@link Account Account} identifier * @param destination destination address or non-custodial account identifier * @param amount amount in source account currency * @param sendMax send maximum possible funds to destination (defaults to false) */ composeCustodyWithdrawTransaction(fromAccountId: string, destination: string, amount: Decimal | null, sendMax?: boolean): Promise<ComposedTransaction>; /** * Compose transaction from user fiat account to user's nominated account. * Refer to <a href="https://developers.zumo.money/docs/guides/send-transactions#nominated-transaction">Send Transactions</a> * guide for usage details. * * @param fromAccountId {@link Account Account} identifier * @param amount amount in source account currency * @param sendMax send maximum possible funds to destination (defaults to false) */ composeNominatedTransaction(fromAccountId: string, amount: Decimal | null, sendMax?: boolean): Promise<ComposedTransaction>; /** * Submit a transaction asynchronously. * Refer to <a href="https://developers.zumo.money/docs/guides/send-transactions#submit-transaction">Send Transactions</a> * guide for usage details. * * @param composedTransaction Composed transaction retrieved as a result * of one of the compose transaction methods * @param toAccountId Debit account id override, only applicable to direct custody deposits. * In case no account id is specified senders custody account will be debited. * @param metadata Optional metadata that will be attached to transaction */ submitTransaction(composedTransaction: ComposedTransaction, toAccountId?: string | null, metadata?: any): Promise<Transaction>; /** * Fetch trading pairs that are currently supported. */ fetchTradingPairs(): Promise<void>; /** * Compose exchange asynchronously. * Refer to <a href="https://developers.zumo.money/docs/guides/make-exchanges#compose-exchange">Make Exchanges</a> * guide for usage details. * * @param debitAccountId {@link Account Account} identifier * @param creditAccountId {@link Account Account} identifier * @param debitAmount amount to be debited from debit account * @param sendMax exchange maximum possible funds (defaults to false) */ composeExchange(debitAccountId: string, creditAccountId: string, debitAmount: Decimal | null, sendMax?: boolean): Promise<ComposedExchange>; /** * Submit an exchange asynchronously. * Refer to <a href="https://developers.zumo.money/docs/guides/make-exchanges#submit-exchange">Make Exchanges</a> * guide for usage details. * * @param composedExchange Composed exchange retrieved as the result * of {@link composeExchange} method */ submitExchange(composedExchange: ComposedExchange): Promise<Exchange>; }