Skip to content

Commit

Permalink
Merge pull request #1226 from jolocom/bug/#1224-demo-version-shouldnt…
Browse files Browse the repository at this point in the history
…-fetch

Bug/#1224 demo version shouldnt fetch
  • Loading branch information
nataschaberg authored Feb 18, 2019
2 parents 1c6c45a + b4b3bf6 commit 42cce76
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/backendMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { Storage } from 'src/lib/storage/storage'
import { KeyChain, KeyChainInterface } from 'src/lib/keychain'
import { ConnectionOptions } from 'typeorm/browser'
import { SoftwareKeyProvider } from 'jolocom-lib/js/vaultedKeyProvider/softwareProvider'
import { DidDocument } from 'jolocom-lib/js/identity/didDocument/didDocument'
import { Identity } from 'jolocom-lib/js/identity/identity'

export class BackendMiddleware {
identityWallet!: IdentityWallet
Expand All @@ -24,9 +26,34 @@ export class BackendMiddleware {
async setIdentityWallet(userVault: SoftwareKeyProvider, pass: string): Promise<void> {
const { jolocomIdentityKey } = JolocomLib.KeyTypes
const registry = JolocomLib.registries.jolocom.create()
this.identityWallet = await registry.authenticate(userVault, {
const pubKey = userVault.getPublicKey({
encryptionPass: pass,
derivationPath: jolocomIdentityKey
})
const keyArgs = {
encryptionPass: pass,
derivationPath: jolocomIdentityKey,
keyId: pubKey.toString('hex')
}

const personas = await this.storageLib.get.persona()

if (personas.length) {
this.identityWallet = new IdentityWallet({
vaultedKeyProvider: userVault,
identity: Identity.fromDidDocument({
didDocument: DidDocument.fromPublicKey(pubKey)
}),
publicKeyMetadata: keyArgs
})
} else {
try {
this.identityWallet = await registry.authenticate(userVault, keyArgs)
} catch(err) {
console.log(err)
}
}

console.warn(this.identityWallet)
}
}

0 comments on commit 42cce76

Please sign in to comment.