Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const ghostDevice = extractGhostDevice(unlockKey);
const { trustchainId, userId, deviceEncryptionKeyPair, deviceSignatureKeyPair } = this._localUser;
const encryptedUserKey = await getLastUserKey(this._client, trustchainId, ghostDevice);
const userKey = decryptUserKeyForGhostDevice(ghostDevice, encryptedUserKey);
const newDeviceBlock = await generateDeviceFromGhostDevice(
trustchainId, userId, deviceEncryptionKeyPair, deviceSignatureKeyPair,
ghostDevice, encryptedUserKey.deviceId, userKey
);
await this._client.send('create device', newDeviceBlock, true);
} catch (e) {
if (e instanceof TankerError) {
throw e;
}
if (verification.verificationKey) {
throw new InvalidVerification(e);
}
throw new InternalError(e);
}
await this.authenticate();
}