How to use the @tanker/identity.createProvisionalIdentity function in @tanker/identity

To help you get started, we’ve selected a few @tanker/identity 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 / encrypt.js View on Github external
it('encrypt and share with a provisional identity', async () => {
        const email = 'alice@tanker-functional-test.io';
        const provisionalIdentity = await createProvisionalIdentity(utils.toBase64(args.appHelper.appId), email);
        const publicProvisionalIdentity = await getPublicIdentity(provisionalIdentity);
        await expect(bobLaptop.encrypt(clearText, { shareWithUsers: [publicProvisionalIdentity] })).to.be.fulfilled;
      });
github TankerHQ / sdk-js / packages / functional-tests / src / verification.js View on Github external
it('fails to attach a provisional identity if the oidc id token contains an email different from the provisional email', async () => {
        await bobLaptop.registerIdentity({ passphrase: 'passphrase' });
        const aliceIdentity = await args.appHelper.generateIdentity();
        const aliceLaptop = args.makeTanker();
        await aliceLaptop.start(aliceIdentity);
        await aliceLaptop.registerIdentity({ passphrase: 'passphrase' });

        const email = 'the-ceo@tanker.io';
        const provisionalIdentity = await createProvisionalIdentity(utils.toBase64(args.appHelper.appId), email);

        const attachResult = await bobLaptop.attachProvisionalIdentity(provisionalIdentity);
        expect(attachResult).to.deep.equal({
          status: bobLaptop.constructor.statuses.IDENTITY_VERIFICATION_NEEDED,
          verificationMethod: { type: 'email', email },
        });

        await expect(bobLaptop.verifyProvisionalIdentity({ oidcIdToken: martineIdToken })).to.be.rejectedWith(errors.InvalidArgument);
        await aliceLaptop.stop();
      });
github TankerHQ / sdk-js / packages / functional-tests / src / verification.js View on Github external
it('decrypt data shared with an attached provisional identity', async () => {
        await bobLaptop.registerIdentity({ passphrase: 'passphrase' });
        const aliceIdentity = await args.appHelper.generateIdentity();
        const aliceLaptop = args.makeTanker();
        await aliceLaptop.start(aliceIdentity);
        await aliceLaptop.registerIdentity({ passphrase: 'passphrase' });

        const email = oidcSettings.googleAuth.users.martine.email;
        const provisionalIdentity = await createProvisionalIdentity(utils.toBase64(args.appHelper.appId), email);
        const publicProvisionalIdentity = await getPublicIdentity(provisionalIdentity);

        const clearText = 'Rivest Shamir Adleman';
        const cipherText = await aliceLaptop.encrypt(clearText, { shareWithUsers: [publicProvisionalIdentity] });

        const attachResult = await bobLaptop.attachProvisionalIdentity(provisionalIdentity);
        expect(attachResult).to.deep.equal({
          status: bobLaptop.constructor.statuses.IDENTITY_VERIFICATION_NEEDED,
          verificationMethod: { type: 'email', email },
        });

        await bobLaptop.verifyProvisionalIdentity({ oidcIdToken: martineIdToken });

        const decrypted = await bobLaptop.decrypt(cipherText);
        expect(decrypted).to.equal(clearText);
        await aliceLaptop.stop();
github TankerHQ / sdk-js / packages / functional-tests / src / groups.js View on Github external
it('share keys with added provisional group members', async () => {
      const provisionalEmail = `${uuid.v4()}@tanker-functional-test.io`;
      const provisionalIdentity = await createProvisionalIdentity(utils.toBase64(args.appHelper.appId), provisionalEmail);
      const provisionalPublicIdentity = await getPublicIdentity(provisionalIdentity);

      const groupId = await bobLaptop.createGroup([bobPublicIdentity]);

      await bobLaptop.updateGroupMembers(groupId, { usersToAdd: [provisionalPublicIdentity] });
      const encrypted = await bobLaptop.encrypt(message, { shareWithGroups: [groupId] });

      const verificationCode = await args.appHelper.getVerificationCode(provisionalEmail);
      await aliceLaptop.attachProvisionalIdentity(provisionalIdentity);
      await aliceLaptop.verifyProvisionalIdentity({ email: provisionalEmail, verificationCode });

      expect(await aliceLaptop.decrypt(encrypted)).to.deep.equal(message);
    });
  });
github TankerHQ / sdk-js / packages / functional-tests / src / encrypt.js View on Github external
beforeEach(async () => {
        email = `${uuid.v4()}@tanker-functional-test.io`;
        provisionalIdentity = await createProvisionalIdentity(utils.toBase64(args.appHelper.appId), email);
        publicProvisionalIdentity = await getPublicIdentity(provisionalIdentity);

        const attachResult = await aliceLaptop.attachProvisionalIdentity(provisionalIdentity);
        expect(attachResult).to.deep.equal({
          status: aliceLaptop.constructor.statuses.IDENTITY_VERIFICATION_NEEDED,
          verificationMethod: { type: 'email', email },
        });
      });
github TankerHQ / quickstart-examples / server / src / server.js View on Github external
await Promise.all(emails.map(async (email) => {
      if (!foundEmails.includes(email)) {
        const user = {
          id: uuid(),
          email,
          provisionalIdentity: await createProvisionalIdentity(serverConfig.appId, email),
        };

        app.storage.save(user);

        users.push(user);
      }
    }));
  }
github TankerHQ / sdk-js / packages / verification-ui / example / index.js View on Github external
createIdentity(appId, appSecret, userId).then(async identity => {
  const provisionalIdentity = await createProvisionalIdentity(appId, email);
  const tanker = new Tanker({ appId, url });
  const verificationUI = new VerificationUI(tanker);
  await verificationUI.start(email, identity, provisionalIdentity);
});