Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('returns a list of public identities (provisional and permanent)', async () => {
const email1 = makeTestEmail();
const email2 = makeTestEmail();
// email1 exists, while email2 is provisional
const priv1 = await fa.getIdentity(email1);
const [pub1, pub2] = await fa.getPublicIdentities([email1, email2]);
const priv2 = await fa.getIdentity(email2);
expectMatchingPublicIdentities(pub1, await getPublicIdentity(priv1.identity));
expectMatchingPublicIdentities(pub2, await getPublicIdentity(priv2.provisionalIdentity));
});
it('returns a list of public identities (provisional and permanent)', async () => {
const email1 = makeTestEmail();
const email2 = makeTestEmail();
// email1 exists, while email2 is provisional
const priv1 = await fa.getIdentity(email1);
const [pub1, pub2] = await fa.getPublicIdentities([email1, email2]);
const priv2 = await fa.getIdentity(email2);
expectMatchingPublicIdentities(pub1, await getPublicIdentity(priv1.identity));
expectMatchingPublicIdentities(pub2, await getPublicIdentity(priv2.provisionalIdentity));
});
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;
});
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);
});
});
it('returns the proper public identity before and after the private identity has been used', async () => {
const email = makeTestEmail();
const [publicProvIdentity1] = await fa.getPublicIdentities([email]);
const { identity, provisionalIdentity } = await fa.getIdentity(email);
const [publicProvIdentity2] = await fa.getPublicIdentities([email]);
await fa.setIdentityRegistered(email);
const [publicPermIdentity] = await fa.getPublicIdentities([email]);
expectMatchingPublicIdentities(publicProvIdentity1, await getPublicIdentity(provisionalIdentity));
expectMatchingPublicIdentities(publicProvIdentity2, await getPublicIdentity(provisionalIdentity));
expectMatchingPublicIdentities(publicPermIdentity, await getPublicIdentity(identity));
});
});
const ghostDeviceKeys = generateGhostDeviceKeys();
const { userCreationBlock, ghostDevice } = generateUserCreation(this._trustchainId, userId, deviceEncryptionKeyPair, deviceSignatureKeyPair, ghostDeviceKeys, delegationToken);
const unverifiedDeviceCreation = ((userEntryFromBlock(userCreationBlock): any): DeviceCreationEntry);
const privateUserKey = tcrypto.sealDecrypt(unverifiedDeviceCreation.user_key_pair.encrypted_private_encryption_key, ghostDeviceKeys.encryptionKeyPair);
const testDevice: TestDevice = {
id: unverifiedDeviceCreation.hash,
signKeys: ghostDeviceKeys.signatureKeyPair,
encryptionKeys: ghostDeviceKeys.encryptionKeyPair,
revoked: false,
isGhost: true,
};
const identity = await createIdentity(utils.toBase64(this._trustchainId), utils.toBase64(this._trustchainKeys.privateKey), utils.toBase64(userId));
const publicIdentity = await getPublicIdentity(identity);
const testUser: TestUser = {
id: userId,
userKeys: [{
publicKey: unverifiedDeviceCreation.user_key_pair.public_encryption_key,
privateKey: privateUserKey,
}],
devices: [testDevice],
ghostDevice,
identity,
publicIdentity,
};
return {
unverifiedDeviceCreation,
block: userCreationBlock,
before(async () => {
aliceIdentity = await args.appHelper.generateIdentity();
alicePublicIdentity = await getPublicIdentity(aliceIdentity);
bobIdentity = await args.appHelper.generateIdentity();
bobPublicIdentity = await getPublicIdentity(bobIdentity);
aliceLaptop = args.makeTanker();
bobLaptop = args.makeTanker();
await aliceLaptop.start(aliceIdentity);
await aliceLaptop.registerIdentity({ passphrase: 'passphrase' });
await bobLaptop.start(bobIdentity);
await bobLaptop.registerIdentity({ passphrase: 'passphrase' });
});
before(async () => {
const aliceIdentity = await args.appHelper.generateIdentity();
alicePublicIdentity = await getPublicIdentity(aliceIdentity);
aliceLaptop = args.makeTanker();
await aliceLaptop.start(aliceIdentity);
await aliceLaptop.registerIdentity({ passphrase: 'passphrase' });
const bobIdentity = await args.appHelper.generateIdentity();
bobPublicIdentity = await getPublicIdentity(bobIdentity);
bobLaptop = args.makeTanker();
await bobLaptop.start(bobIdentity);
await bobLaptop.registerIdentity({ passphrase: 'passphrase' });
unknownPublicIdentity = await getPublicIdentity(await args.appHelper.generateIdentity('galette'));
});
before(async () => {
aliceIdentity = await args.appHelper.generateIdentity();
bobIdentity = await args.appHelper.generateIdentity();
bobPublicIdentity = await getPublicIdentity(bobIdentity);
aliceLaptop = args.makeTanker();
bobLaptop = args.makeTanker();
await aliceLaptop.start(aliceIdentity);
await aliceLaptop.registerIdentity({ passphrase: 'passphrase' });
await bobLaptop.start(bobIdentity);
await bobLaptop.registerIdentity({ passphrase: 'passphrase' });
setupTestData();
});
before(async () => {
const aliceIdentity = await args.appHelper.generateIdentity();
alicePublicIdentity = await getPublicIdentity(aliceIdentity);
aliceLaptop = args.makeTanker();
await aliceLaptop.start(aliceIdentity);
await aliceLaptop.registerIdentity({ passphrase: 'passphrase' });
const bobIdentity = await args.appHelper.generateIdentity();
bobPublicIdentity = await getPublicIdentity(bobIdentity);
bobLaptop = args.makeTanker();
await bobLaptop.start(bobIdentity);
await bobLaptop.registerIdentity({ passphrase: 'passphrase' });
unknownPublicIdentity = await getPublicIdentity(await args.appHelper.generateIdentity('galette'));
});