How to use the @tanker/core.errors.DeviceRevoked function in @tanker/core

To help you get started, we’ve selected a few @tanker/core 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 / functional-tests / src / revocation.js View on Github external
it('Alice can share with Bob who has a revoked device', async () => {
      const aliceIdentity = await args.appHelper.generateIdentity();
      const aliceLaptop = args.makeTanker();
      await aliceLaptop.start(aliceIdentity);
      await aliceLaptop.registerIdentity({ passphrase: 'passphrase' });


      await bobLaptop.revokeDevice(bobPhone.deviceId);

      const message = 'I love you';
      const encrypted = await aliceLaptop.encrypt(message, { shareWithUsers: [bobPublicIdentity] });

      const clear = await bobLaptop.decrypt(encrypted);
      expect(clear).to.eq(message);

      await expect(bobPhone.decrypt(encrypted)).to.be.rejectedWith(errors.DeviceRevoked);
      await aliceLaptop.stop();
    });
  });
github TankerHQ / sdk-js / packages / functional-tests / src / revocation.js View on Github external
it('fires a revoked event on the revoked device only', async () => {
      bobLaptop.on('deviceRevoked', () => {
        expect(false).to.be.true;
      });
      await bobLaptop.revokeDevice(bobPhone.deviceId);

      let eventCalled = false;
      bobPhone.on('deviceRevoked', () => {
        eventCalled = true;
      });
      await expect(bobPhone.encrypt('message')).to.be.rejectedWith(errors.DeviceRevoked);
      await expect(eventCalled).to.be.true;
    });