Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | 1x 1x 4x 4x 9x 17x 3x 3x 8x 1x 19x 17x 2x 9x 27x | import { EventComponent } from '@affinidi/affinity-metrics-lib' import { NetworkMemberWithCognito as Wallet } from '../CommonNetworkMember/NetworkMemberWithCognito' import { KeyParamsOrOptions, MessageParameters, SdkOptions, TokenTrueCaller } from '../dto/shared.dto' import { IPlatformCryptographyTools } from '../shared/interfaces' export const createCognitoWalletFactories = ( platformCryptographyTools: IPlatformCryptographyTools, eventComponent: EventComponent, ) => { const dependencies = { platformCryptographyTools, eventComponent } return { /** * @description Initiates passwordless login to Affinity * @param options - parameters with specified environment * @param login - email/phoneNumber, registered in Cognito * @param messageParameters - optional parameters with specified welcome message * @returns token */ initiateLogInPasswordless: (inputOptions: SdkOptions, login: string, messageParameters?: MessageParameters) => { return Wallet.initiateLogInPasswordless(inputOptions, login, messageParameters) }, /** * @description Completes login * @param options - parameters for BaseNetworkMember initialization * @param token - returned by initiateLogInPasswordless * @param confirmationCode - OTP sent by AWS Cognito/SES * @returns initialized instance of SDK */ completeLogInPasswordless: (inputOptions: SdkOptions, token: string, confirmationCode: string) => { return Wallet.completeLogInPasswordless(dependencies, inputOptions, token, confirmationCode) }, /** * @description Initiates reset password flow * @param options - parameters with specified environment * @param login - email/phoneNumber, registered in Cognito * @param messageParameters - optional parameters with specified welcome message * @returns token to be used with completeForgotPassword */ initiateForgotPassword: (inputOptions: SdkOptions, login: string, messageParameters?: MessageParameters) => { return Wallet.initiateForgotPassword(inputOptions, login, messageParameters) }, /** * @description Completes reset password flow * @param options - parameters with specified environment * @param forgotPasswordToken - token returned by initiateForgotPassword * @param confirmationCode - OTP sent by AWS Cognito/SES * @param newPassword - new password * @returns initialized instance of SDK */ completeForgotPassword: ( inputOptions: SdkOptions, forgotPasswordToken: string, confirmationCode: string, newPassword: string, ) => { return Wallet.completeForgotPassword( dependencies, inputOptions, forgotPasswordToken, confirmationCode, newPassword, ) }, /** * @description Logins to Affinity with login and password * @param options - optional parameters for BaseNetworkMember initialization * @param login - arbitrary username or email or phone number, registered in Cognito * @param password - password for Cognito user * @returns initialized instance of SDK */ logInWithPassword: (inputOptions: SdkOptions, username: string, password: string) => { return Wallet.logInWithPassword(dependencies, inputOptions, username, password) }, /** * @description Logins to Affinity with refreshToken * Take care about refresh token to save it in right place, its lifetime is 30 days. * To invalidate tokens please use wallet.logOut() method. * The best way to use only access token and re-login user each hour (lifetime of accessToken) * @param inputOptions - optional parameters for BaseNetworkMember initialization * @param refreshToken - refresh token * @returns initialized instance of SDK */ logInWithRefreshToken: (inputOptions: SdkOptions, refreshToken: string) => { return Wallet.logInWithRefreshToken(dependencies, inputOptions, refreshToken) }, /** * @description Initiates sign up flow to Affinity wallet, optionally with already created did * @param inputOptiosn - parameters with specified environment * @param username - arbitrary username * @param password - password * @param keyParamsOrOptions (optional) - { encryptedSeed, password } - previously created keys to be stored at wallet * @returns initialized instance of SDK */ signUpWithUsername: ( inputOptions: SdkOptions, username: string, password: string, keyParamsOrOptions?: KeyParamsOrOptions, ) => { return Wallet.signUpWithUsername(dependencies, inputOptions, username, password, keyParamsOrOptions) }, /** * @description Initiates sign up flow * @param options - parameters with specified environment * @param email - email address * @param password (optional) - if not provided, a random password will be generated * @param messageParameters (optional) - parameters with specified welcome message * @returns token */ initiateSignUpByEmail: ( inputOptions: SdkOptions, email: string, password?: string | null, messageParameters?: MessageParameters, ) => { return Wallet.initiateSignUpByEmail(inputOptions, email, password, messageParameters) }, /** * @description Initiates sign up flow * @param options - parameters with specified environment * @param phone - phone number * @param password (optional) - if not provided, a random password will be generated * @param messageParameters (optional) - parameters with specified welcome message * @returns token */ initiateSignUpByPhone: ( inputOptions: SdkOptions, phone: string, password?: string | null, messageParameters?: MessageParameters, ) => { return Wallet.initiateSignUpByPhone(inputOptions, phone, password, messageParameters) }, /** * @description Completes sign up flow, optionally with already created did * (as result created keys will be stored at the Affinity Wallet) * @param options - optional parameters for BaseNetworkMember initialization * @param token - Token returned by initiateSignUp method. * @param confirmationCode - OTP sent by AWS Cognito/SES. * @param keyParamsOrOptions (optional) - { encryptedSeed, password } - previously created keys to be stored at wallet. * @returns initialized instance of SDK */ completeSignUp: ( inputOptions: SdkOptions, signUpToken: string, confirmationCode: string, keyParamsOrOptions?: KeyParamsOrOptions, ) => { return Wallet.completeSignUp(dependencies, inputOptions, signUpToken, confirmationCode, keyParamsOrOptions) }, /** * @description Resends OTP for sign up flow * @param inputOptions - parameters with specified environment * @param signUpToken - token returned by `initiateSignUp...` * @param messageParameters (optional) - parameters with specified welcome message */ resendSignUp: (inputOptions: SdkOptions, signUpToken: string, messageParameters?: MessageParameters) => { return Wallet.resendSignUp(inputOptions, signUpToken, messageParameters) }, /** * @description Initiates passwordless sign in of an existing user, * or signs up a new one, if user was not registered * @param options - optional parameters with specified environment * @param username - email or phone number * @param messageParameters - optional parameters with specified welcome message * @returns token */ initiateSignInPasswordless: (inputOptions: SdkOptions, login: string, messageParameters?: MessageParameters) => { return Wallet.initiateSignInPasswordless(inputOptions, login, messageParameters) }, /** * @description Completes sign in * @param options - optional parameters for BaseNetworkMember initialization * @param token - received from #signIn method * @param confirmationCode - OTP sent by AWS Cognito/SES * @returns an object with a flag, identifying whether new account was created, and initialized instance of SDK */ completeSignInPasswordless: (options: SdkOptions, signInToken: string, confirmationCode: string) => { return Wallet.completeSignInPasswordless(dependencies, options, signInToken, confirmationCode) }, /** * @description Initiates sign in of an existing user with `Truecaller` token, * or signs up a new one, if user was not registered * @param inputOptions - optional parameters with specified environment * @param profileTrueCaller - `Truecaller` token/profile * @returns an object with a flag, identifying whether new account was created, and initialized instance of SDK */ signInWithProfile: (inputOptions: SdkOptions, profileTrueCaller: TokenTrueCaller) => { return Wallet.signInWithProfile(inputOptions, profileTrueCaller, dependencies) }, /** * @description Creates a new instance of SDK from string returned by `serialize` * @param options - parameters for AffinityWallet initialization * @param serializedWallet * @returns initialized instance of SDK */ deserializeSession: (inputOptions: SdkOptions, serializedSession: string) => { return Wallet.deserializeSession(dependencies, inputOptions, serializedSession) }, } } |