import OreIdContext from '../core/IOreidContext'; import { ChainAccount, ChainNetwork, ExternalWalletInterface, ExternalWalletType, LoginWithWalletOptions, SignatureProviderSignResult, SignStringParams, TransactionData } from '../models'; import { User } from '../user/user'; import { ConnectToUalProviderParams, ConnectToUalProviderResult, UalAuthenticatorFactory, UalUser, UserAccountPermissions } from './models'; import { Authenticator } from 'universal-authenticator-library'; export default class UalHelper { constructor(args: { oreIdContext: OreIdContext; user: User; }); _oreIdContext: OreIdContext; _user: User; /** Verifies that all plugins have a valid name * Stores a list of the installed providerNames for all working plugins in ualProvidersInstalled */ installUalProviders(ualWalletProviders: UalAuthenticatorFactory[]): Promise; /** Retrieve the user and their account/permission details for the matching chainNetwork * Returns null if nothing in wallet for chainNetwork */ loginToUalProvider(walletType: ExternalWalletType, authenticator: Authenticator, chainNetwork: ChainNetwork, chainAccount: ChainAccount): Promise<{ user: UalUser; userPermissions: UserAccountPermissions; }>; connectToUalProvider({ walletType, chainNetwork, chainAccount, }: ConnectToUalProviderParams): Promise; /** Extract user account/permission for all publicKeys in the User's wallet */ getAccountAndPermissionsFromUalUser(ualUser: UalUser): Promise; /** Login using the wallet provider */ loginWithUalProvider(loginOptions: LoginWithWalletOptions): Promise; /** Throw if the required plug-in is not installed */ assertHasProviderInstalled(provider: ExternalWalletType, providerType: ExternalWalletInterface): void; /** sign with a UAL wallet */ signWithUalProvider(transactionData: TransactionData, walletType: ExternalWalletType): Promise<{ signedTransaction: SignatureProviderSignResult; }>; /** Signs an arbitrary string using a specific provider */ signStringWithUalProvider({ walletType, chainNetwork, string, chainAccount, message }: SignStringParams): Promise<{ signedString: string; }>; /** Add the account selected in the UAL User to the ORE account's list of account/permissions */ updateOreAccountPermissionsfromUalUser(user: UalUser, walletType: ExternalWalletType): Promise; /** Whether this UAL provider was installed upon instantiation */ isUalProvider(walletType: ExternalWalletType): boolean; /** Whether this UAL provider was installed upon instantiation */ hasUalProvider(walletType: ExternalWalletType): boolean; /** * get user account keys * some wallets don't support getKeys */ getKeys(ualUser: UalUser): Promise; /** Throw if the provider doesnt support the specified chainNetwork */ assertProviderValidForChainNetwork(walletType: ExternalWalletType, chainNetwork: ChainNetwork): Promise; /** set isBusy on oreIdContext while wallet authenticator isLoading */ private waitWhileWalletIsBusy; /** 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; }; }