All files / src/shared getDidData.ts

100% Statements 13/13
100% Branches 0/0
100% Functions 2/2
100% Lines 11/11

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 221x   1x 137x 137x 137x   137x     1x           137x 137x 137x 137x    
import { DidDocumentService, KeysService } from '@affinidi/common'
 
export const getDidDataFromKeysService = (keysService: KeysService) => {
  const didDocumentService = DidDocumentService.createDidDocumentService(keysService)
  const did = didDocumentService.getMyDid()
  const didDocumentKeyId = didDocumentService.getKeyId()
 
  return { did, didDocumentKeyId }
}
 
export const withDidData = (userData: {
  encryptedSeed: string
  password: string
  didDocument?: any
  accountNumber?: number
}) => {
  const { encryptedSeed, password, didDocument, accountNumber } = userData
  const keysService = new KeysService(encryptedSeed, password, accountNumber)
  const { did, didDocumentKeyId } = getDidDataFromKeysService(keysService)
  return { did, didDocumentKeyId, encryptedSeed, password, didDocument, accountNumber }
}