How to use the @tanker/errors.InvalidVerification function in @tanker/errors

To help you get started, we’ve selected a few @tanker/errors examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TankerHQ / sdk-js / packages / core / src / LocalUser / Manager.js View on Github external
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();
  }