import { SdkOptions, CognitoUserTokens, MessageParameters, KeyParams } from '../dto/shared.dto'; import { ParsedOptions } from '../shared/getOptionsFromEnvironment'; import { StaticDependencies, ConstructorUserData } from './BaseNetworkMember'; import { LegacyNetworkMember } from './LegacyNetworkMember'; declare type UserDataWithCognito = ConstructorUserData & { cognitoUserTokens: CognitoUserTokens | undefined; }; /** * @deprecated, will be removed in SDK v7 */ export declare class LegacyNetworkMemberWithFactories extends LegacyNetworkMember { private readonly _userManagementService; protected cognitoUserTokens: CognitoUserTokens | undefined; private _keysService; constructor(userData: UserDataWithCognito, dependencies: StaticDependencies, options: ParsedOptions); /** * @description Returns user's accessToken * @returns encrypted seed */ get accessToken(): string; /** * @description Checks if registration for the user was completed * @param username - a valid email, phone number or arbitrary username * @param inputOptions - object with environment, dev is default { env: 'dev' } * @returns `true` if user is uncofirmed in Cognito, and `false` otherwise. */ static isUserUnconfirmed(username: string, inputOptions: SdkOptions): Promise; /** * @description Initilizes instance of SDK from seed * @param seedHexWithMethod - seed for derive keys in string hex format * @param inputOptions - optional parameter { registryUrl: 'https://affinity-registry.apse1.dev.affinidi.io' } * @param password - optional password, will be generated, if not provided * @returns initialized instance of SDK */ static fromSeed(dependencies: StaticDependencies, seedHexWithMethod: string, inputOptions: SdkOptions, password?: string): Promise; /** * @description Pulls encrypted seed from Affinity Guardian Wallet * 1. get AWS cognito access token * 2. using access token pull encrypted seed from Affinity Guardian Wallet * associated with this AWS Cognito userId * @param username - email or phone number used to create Affinity user * @param inputPassword - password used on create Affinity user */ pullEncryptedSeed(username: string, inputPassword: string): Promise; /** * @description Saves encrypted seed to Guardian Wallet * @param username - email/phoneNumber, registered in Cognito * @param inputPassword - password for Cognito user * @param token - Cognito access token, required for authorization. * If not provided, in order to get it, sign in to Cognito will be initiated. */ storeEncryptedSeed(username: string, inputPassword: string, token?: string): Promise; /** * @description Initiates passwordless login to Affinity * @param username - email/phoneNumber, registered in Cognito * @param options - optional parameters with specified environment * @param messageParameters - optional parameters with specified welcome message * @returns token */ static passwordlessLogin(login: string, inputOptions: SdkOptions, messageParameters?: MessageParameters): Promise; /** * @description Completes login * @param token - received from #passwordlessLogin method * @param confirmationCode - OTP sent by AWS Cognito/SES * @param options - optional parameters for BaseNetworkMember initialization * @returns initialized instance of SDK */ static completeLoginChallenge(dependencies: StaticDependencies, token: string, confirmationCode: string, inputOptions: SdkOptions): Promise; /** * @description Signs out current user */ signOut(inputOptions: SdkOptions): Promise; /** * @description Initiates reset password flow * @param username - email/phoneNumber, registered in Cognito * @param options - optional parameters with specified environment * @param messageParameters - optional parameters with specified welcome message */ static forgotPassword(login: string, inputOptions: SdkOptions, messageParameters?: MessageParameters): Promise; /** * @description Completes reset password flow * @param username - email/phoneNumber, registered in Cognito * @param confirmationCode - OTP sent by AWS Cognito/SES * @param newPassword - new password * @param options - optional parameters with specified environment */ static forgotPasswordSubmit(login: string, confirmationCode: string, newPassword: string, inputOptions: SdkOptions): Promise; /** * @description Logins to Affinity with login and password * @param username - email/phoneNumber, registered in Cognito * @param inputPassword - password for Cognito user * @param options - optional parameters for BaseNetworkMember initialization * @returns initialized instance of SDK */ static fromLoginAndPassword(dependencies: StaticDependencies, username: string, inputPassword: string, inputOptions: SdkOptions): Promise; /** * @description Initiates sign up flow to Affinity wallet with already created did * @param keyParams - { ecnryptedSeed, password } - previously created keys to be storead at wallet. * @param username - arbitrary username, email or phoneNumber * @param inputPassword - is required if arbitrary username was provided. * It is optional and random one will be generated, if not provided when * email or phoneNumber was given as a username. * @param options - optional parameters with specified environment * @param messageParameters - optional parameters with specified welcome message * @returns token or, in case when arbitrary username was used, it returns * initialized instance of SDK */ static signUpWithExistsEntity(dependencies: StaticDependencies, keyParams: KeyParams, login: string, inputPassword: string, inputOptions: SdkOptions, messageParameters?: MessageParameters): Promise; private static _signUpByUsernameAutoConfirm; private static _signUpByEmailOrPhone; /** * @description Initiates sign up flow * @param username - arbitrary username, email or phoneNumber * @param password - is required if arbitrary username was provided. * It is optional and random one will be generated, if not provided when * email or phoneNumber was given as a username. * @param options - optional parameters with specified environment * @param messageParameters - optional parameters with specified welcome message * @returns token or, in case when arbitrary username was used, it returns * initialized instance of SDK */ static signUp(dependencies: StaticDependencies, login: string, password: string, inputOptions: SdkOptions, messageParameters?: MessageParameters): Promise; /** * @description Completes sign up flow with already created did * (as result created keys will be stored at the Affinity Wallet) * NOTE: no need calling this method in case of arbitrary username was given, * as registration is already completed * NOTE: This method will throw an error if called for arbitrary username * @param keyParams - { ecnryptedSeed, password } - previously created keys to be storead at wallet. * @param token - Token returned by signUpWithExistsEntity method. * @param confirmationCode - OTP sent by AWS Cognito/SES. * @param options - optional parameters for BaseNetworkMember initialization * @returns initialized instance of SDK */ static confirmSignUpWithExistsEntity(dependencies: StaticDependencies, keyParams: KeyParams, signUpToken: string, confirmationCode: string, inputOptions: SdkOptions): Promise; private static _confirmSignUp; /** * @description Completes sign up flow * NOTE: no need calling this method in case of arbitrary username was given, * as registration is already completed. * NOTE: this method will throw an error if called for arbitrary username * @param confirmationCode - OTP sent by AWS Cognito/SES. * @param options - optional parameters for BaseNetworkMember initialization * @returns initialized instance of SDK */ static confirmSignUp(dependencies: StaticDependencies, signUpToken: string, confirmationCode: string, inputOptions: SdkOptions, key?: string, passwordless?: boolean): Promise; private afterConfirmSignUp; /** * @description Resends OTP for sign up flow * @param username - email/phoneNumber, registered and unconfirmed in Cognito * @param options - optional parameters with specified environment * @param messageParameters - optional parameters with specified welcome message */ static resendSignUpConfirmationCode(login: string, inputOptions: SdkOptions, messageParameters?: MessageParameters): Promise; /** * @description Initiates passwordless sign in of an existing user, * or signs up a new one, if user was not registered * @param username - email/phoneNumber, registered in Cognito * @param options - optional parameters with specified environment * @param messageParameters - optional parameters with specified welcome message * @returns token */ static signIn(login: string, inputOptions: SdkOptions, messageParameters?: MessageParameters): Promise; /** * @description Completes sign in * @param token - received from #signIn method * @param confirmationCode - OTP sent by AWS Cognito/SES * @param options - optional parameters for BaseNetworkMember initialization * @returns an object with a flag, identifying whether new account was created, and initialized instance of SDK */ static confirmSignIn(dependencies: StaticDependencies, token: string, confirmationCode: string, options: SdkOptions): Promise<{ isNew: boolean; commonNetworkMember: LegacyNetworkMemberWithFactories; }>; /** * @description Initiates change user password * @param oldPassword * @param newPassword * @param options - optional parameters with specified environment */ changePassword(oldPassword: string, newPassword: string, inputOptions: SdkOptions): Promise; /** * @description Initiates change user attribute (email/phoneNumber) flow * @param newLogin - new email/phoneNumber * @param options - optional parameters with specified environment * @param messageParameters - optional parameters with specified welcome message */ changeUsername(newLogin: string, inputOptions: SdkOptions, messageParameters?: MessageParameters): Promise; /** * @description Completes change user attribute (email/phoneNumber) flow * @param newUsername - new email/phoneNumber * @param confirmationCode - OTP sent by AWS Cognito/SES * @param options - optional parameters with specified environment */ confirmChangeUsername(newLogin: string, confirmationCode: string, inputOptions: SdkOptions): Promise; /** * @description Creates a new instance of SDK by access token * @param accessToken * @param options - optional parameters for AffinityWallet initialization * @returns initialized instance of SDK */ static fromAccessToken(dependencies: StaticDependencies, accessToken: string, inputOptions: SdkOptions): Promise; /** * @description Logins with access token of Cognito user registered in Affinity * @param options - optional parameters for AffinityWallet initialization * @returns initialized instance of SDK or throws `COR-9` UnprocessableEntityError, * if user is not logged in. */ static init(dependencies: StaticDependencies, inputOptions: SdkOptions): Promise; static legacyConstructor(dependencies: StaticDependencies, password: string, encryptedSeed: string, inputOptions: SdkOptions): LegacyNetworkMemberWithFactories; } export {};