import { MakeWalletProviderFn } from '@aikon/eos-transit'; import OreIdContext from '../core/IOreidContext'; import { AuthProvider, ChainAccount, ChainNetwork, ConnectToTransitProviderParams, DiscoverOptions, ExternalWalletInterface, ExternalWalletType, LoginWithWalletOptions, PermissionName, PublicKey, SetupTransitWalletParams, SignatureProviderSignResult, SignStringParams, TransactionData, TransitWallet, WalletPermission } from '../models'; import { TransitWalletAccessContext } from '.'; import { User } from '../user/user'; declare type ConnectToTransitProviderResult = { isLoggedIn?: boolean; chainAccount?: ChainAccount; permissions?: [{ name: PermissionName; publicKey: PublicKey; }]; transitWallet?: TransitWallet; provider?: ExternalWalletType; }; export default class TransitHelper { constructor(args: { oreIdContext: OreIdContext; user: User; }); _oreIdContext: OreIdContext; _user: User; transitAccessContexts: { [key: string]: TransitWalletAccessContext; }; /** Verifies that all plugins provided work (can be constructed) * Stores a list of the installed providerNames (mapped to ExternalWalletType) for all working plugins in transitProvidersInstalled */ installTransitProviders(eosTransitWalletProviders: MakeWalletProviderFn[]): Promise; /** Inialize EOS Transit wallet provider and return TransitWallet instance */ setupTransitWallet({ walletType, chainNetwork }: SetupTransitWalletParams): Promise; /** Creates an EOS Transit WalletContent for the specified network and plugins * Caches the context for future calls to this function */ private getOrCreateTransitAccessContext; /** Handles the call to connect() function on the Transit provider */ connectToTransitProvider({ walletType, chainNetwork, chainAccount, }: ConnectToTransitProviderParams): Promise; /** Handles the call to login() function on the Transit provider * If required by provider, calls discover() and/or logout() before calling login() * IMPORTANT: use loginToTransitProvider() instead of this function */ private doTransitProviderLogin; /** Login using the wallet provider */ loginWithTransitProvider(loginOptions: LoginWithWalletOptions): Promise; /** Handles the call to login() function on the Transit provider */ private loginToTransitProvider; /** Throw if the required plug-in is not installed */ assertHasProviderInstalled(provider: ExternalWalletType, providerType: ExternalWalletInterface): void; /** Discovers keys in a wallet provider. * Any new keys discovered in wallet are added to user's ORE ID record. * If the provider doesnt support a discover() function, and requiresLogoutLoginToDiscover == true, attempts a logout then login instead. */ discoverWithTransit(discoverOptions: DiscoverOptions): Promise; /** Discover all accounts (and related permissions) in the wallet and add them to ORE ID * Note: Most wallets don't support discovery */ private discoverCredentialsInTransitWallet; /** Discover options composed for specific provider */ private discoverOptionsForProvider; private findAccountInDiscoverData; /** sign with a Transit wallet */ signWithTransitProvider(transactionData: TransactionData, walletType: ExternalWalletType): Promise<{ signedTransaction: SignatureProviderSignResult; }>; signStringWithTransitProvider({ walletType, chainNetwork, string, message, metadata }: SignStringParams): Promise<{ signedString: string; }>; /** sign transaction using EOS SDK .transact function */ private signTransactionWithTransitAndEosSDK; /** sign transaction using Algorand SDK */ private signTransactionWithTransitAndAlgorandSDK; /** sign transaction using ethereum web3 SDK */ private signTransactionWithTransitAndEthereumSDK; /** Determine the chainNetwork from the transitWallet context */ getChainNetworkFromTransitWallet(transitWallet: TransitWallet): Promise; /** Add the account selected in the transitWallet to the ORE account's list of account/permissions */ updateOreAccountPermissionsfromTransitWalletAuth(transitWallet: TransitWallet, walletType: ExternalWalletType): Promise; isTransitProvider(provider: AuthProvider | ExternalWalletType): boolean; /** Whether this Eos Transit provider was installed upon instantiation */ hasTransitProvider(walletType: ExternalWalletType): boolean; /** Throw if the provider doesnt support the specified chainNetwork */ assertProviderValidForChainNetwork(walletType: ExternalWalletType, chainNetwork: ChainNetwork): Promise; private waitWhileWalletIsBusy; /** Discovers keys in a wallet provider. * Any new keys discovered in wallet are added to user's ORE ID record. * If the provider doesnt support a discover() function, and requiresLogoutLoginToDiscover == true, attempts a logout then login instead. */ discover(discoverOptions: DiscoverOptions): Promise; /** Call discover after signing so we capture and save the account * Note: This is needed for Ethereum since we dont know a public key until we sign with an account */ callDiscoverAfterSign(transactionData: TransactionData): Promise; /** whether discovery is supported by the provider */ canDiscover(walletType: ExternalWalletType): boolean; /** whether signString is supported by the provider */ canSignString(walletType: ExternalWalletType): boolean; /** whether call to discover is required by provider before login */ requiresDiscoverToLogin(walletType: ExternalWalletType): boolean; /** whether call to logout then login is required by provider before discover */ requiresLogoutLoginToDiscover(walletType: ExternalWalletType): boolean; /** default path index for provider (if any) */ defaultDiscoveryPathIndexList(walletType: ExternalWalletType): number[]; /** help text displayed to user for provider */ helpTextForProvider(walletType: ExternalWalletType): { login: string; sign: string; discover: string; versionsRequired: string; }; } export {};