Skip to content

Commit

Permalink
implement skipIdentityCreation feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
mnzaki committed Aug 14, 2019
1 parent ecbc828 commit a489bdb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/actions/registration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const createIdentity = (encodedEntropy: string): ThunkAction => async (

dispatch(setIsRegistering(true))

const { encryptionLib, keyChainLib, storageLib, registry } = backendMiddleware
const { encryptionLib, keyChainLib, storageLib, registry, fuelKeyWithEther } = backendMiddleware

const password = await keyChainLib.getPassword()
const encEntropy = encryptionLib.encryptWithPass({
Expand All @@ -81,7 +81,7 @@ export const createIdentity = (encodedEntropy: string): ThunkAction => async (

dispatch(setLoadingMsg(loading.loadingStages[1]))

await JolocomLib.util.fuelKeyWithEther(
await fuelKeyWithEther(
userVault.getPublicKey({
encryptionPass: password,
derivationPath: JolocomLib.KeyTypes.ethereumKey,
Expand Down
12 changes: 12 additions & 0 deletions src/backendMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ import { IpfsCustomConnector } from './lib/ipfs'
import { jolocomContractsAdapter } from 'jolocom-lib/js/contracts/contractsAdapter'
import { jolocomEthereumResolver } from 'jolocom-lib/js/ethereum/ethereum'
import { jolocomContractsGateway } from 'jolocom-lib/js/contracts/contractsGateway'
import { skipIdentityRegisteration } from './config';

export class BackendMiddleware {
public identityWallet!: IdentityWallet
public storageLib: Storage
public encryptionLib: EncryptionLibInterface
public keyChainLib: KeyChainInterface
public registry: IRegistry
public fuelKeyWithEther: typeof JolocomLib.util.fuelKeyWithEther

public constructor(config: {
fuelingEndpoint: string
Expand All @@ -26,6 +28,7 @@ export class BackendMiddleware {
this.storageLib = new Storage(config.typeOrmConfig)
this.encryptionLib = new EncryptionLib()
this.keyChainLib = new KeyChain()
this.fuelKeyWithEther = JolocomLib.util.fuelKeyWithEther
this.registry = createJolocomRegistry({
ipfsConnector: new IpfsCustomConnector({
host: 'ipfs.jolocom.com',
Expand All @@ -38,6 +41,15 @@ export class BackendMiddleware {
gateway: jolocomContractsGateway,
},
})
if (skipIdentityRegisteration) {
this.registry.commit = this.fuelKeyWithEther = async (arg: any) => undefined
this.setIdentityWallet = async function(
userVault: SoftwareKeyProvider,
pass: string,
): Promise<void> {
this.identityWallet = await this.registry.create(userVault, pass)
}
}
}

public async initStorage(): Promise<void> {
Expand Down

0 comments on commit a489bdb

Please sign in to comment.