All files / src/factories cognitolessWalletFactories.ts

100% Statements 7/7
100% Branches 0/0
100% Functions 3/3
100% Lines 6/6

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    1x       1x       4x   4x                 15x                                 2x        
import { EventComponent } from '@affinidi/affinity-metrics-lib'
 
import { NetworkMemberWithoutCognito as Wallet } from '../CommonNetworkMember/NetworkMemberWithoutCognito'
import { KeyOptions, SdkOptions } from '../dto/shared.dto'
import { IPlatformCryptographyTools } from '../shared/interfaces'
 
export const createCognitolessWalletFactories = (
  platformCryptographyTools: IPlatformCryptographyTools,
  eventComponent: EventComponent,
) => {
  const dependencies = { platformCryptographyTools, eventComponent }
 
  return {
    /**
     * @description Generates a new DID and creates a new instance of SDK using password
     * @param inputOptions - parameters with specified environment
     * @param inputPassword - password
     * @param keyOptions - specifies available wallet key types (allowed rsa and bbs; ecdsa - default, no need to specify)
     * @returns initialized instance of SDK
     */
    createWallet: (inputOptions: SdkOptions, inputPassword: string, keyOptions?: KeyOptions) => {
      return Wallet.createWallet(dependencies, inputOptions, inputPassword, keyOptions)
    },
 
    /**
     * @description Initilizes instance of SDK from seed
     * @param inputOptions - parameters with specified environment
     * @param encryptedSeed - encrypted seed
     * @param password - password
     * @param accountNumber - account number is an optional parameter to derive custom account `keys`/`did` from the root `seed`
     * @returns initialized instance of SDK
     */
    openWalletByEncryptedSeed: (
      inputOptions: SdkOptions,
      encryptedSeed: string,
      password: string,
      accountNumber?: number,
    ) => {
      return Wallet.openWalletByEncryptedSeed(dependencies, inputOptions, encryptedSeed, password, accountNumber)
    },
  }
}