Cleanup - unused files / unused exports / duplicate exports
[ProtonMail-WebClient.git] / packages / shared / test / keys / driveKeys.spec.ts
blob8278359becee51db835fad9480dabc090657b662
1 import { CryptoProxy } from '@proton/crypto';
3 import { decryptUnsigned } from '../../lib/keys/driveKeys';
5 const shareKey =
6     '-----BEGIN PGP PRIVATE KEY BLOCK-----\r\nVersion: OpenPGP.js v4.4.7\r\nComment: https://openpgpjs.org\r\n\r\nxYYEXc5yKRYJKwYBBAHaRw8BAQdA7YwZxjkyb1yO+SbFT9fIgjIec6vjvFv8\r\nALFUUkDfFlH+CQMIlbaxxwTqxCxg2HU8LGqFPpBAD0A/TvV9kXdZwhycrEDn\r\nKy/2v6wWMSp5gzXgX1FxhOmg5uWNhW3P9/dIt32F+fRrolr+uljAvZB7zBN1\r\nWM0XSm9obiBEb2UgPGpvaG5AZG9lLmRvZT7CdwQQFgoAHwUCXc5yKQYLCQcI\r\nAwIEFQgKAgMWAgECGQECGwMCHgEACgkQ8y3YQiuJcn7Y+AEAzPynnBV2cjd2\r\nVrDtpNVXiGIk3CSSqEl5fpgRyxuD4HoBALcyYPyaJxPxNml99ZZ3p4GuJ474\r\nobF83u/7Lk6vhJ0Px4sEXc5yKRIKKwYBBAGXVQEFAQEHQPnJbOsSgJnu399H\r\niMn8iV8kMNkO65lkaofKmdwPUTQMAwEIB/4JAwjxK/aFhMu7xWCx5fIR519p\r\n3cxxTRdUo09VrK9Fm7fXKa6+GIPccTabyy53dZ9edneZ+GZRRQOos/vG+3zS\r\n3ICeUYGyVT3H5WkUqc+zl18LwmEEGBYIAAkFAl3OcikCGwwACgkQ8y3YQiuJ\r\ncn4i5gD7BQX8rl0tRIcNpY+e71mIbx+/+PANMzlGXNBxtySpXAgBAKKgI/3M\r\npNM92ezA6/XB7O5b0dhooMQvwAxSOS1W07kA\r\n=U3/f\r\n-----END PGP PRIVATE KEY BLOCK-----\r\n'.trim();
7 const addressKey =
8     '-----BEGIN PGP PRIVATE KEY BLOCK-----\nVersion: Proton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xbU6osRw765aEvr/UEsly3+qMRbs1sS6R5HIGycW1h\nUIXLkkcsaFmo1qyQaQrb1rYM9U1qBW9/lr0RxEDz0ciTXR1rsOLtBsgghD95\n2vlxPwhS9ySKTOkbGonX3USthWhztQtJVqoAbXvaoZ05Uva6gOd67phmBMNS\nVaCK5KLhNgGQmH6O0gcAhDoYj5HEKEsSS6nVVbALkhHuIjXJKDpx0eBB2UkU\nUqwHsAWcsxCUreXSsr1X0AMNtmP9iMTNnUSm6/0rmnUwA6/uPtasng8MPtYQ\n7W+fRSMAVfXUqGg24pQm0PZK7mQ=\n=HFGf\n-----END PGP PRIVATE KEY BLOCK-----\n';
9 const passphrase =
10     '-----BEGIN PGP MESSAGE-----\nVersion: ProtonMail\n\nwcBMA6rw6TH9oRKuAQf/dm5wc29Oi51Ieq/miflqQ4rxGvfhe4WD4L9zPxOe\nfe1nndclW0I/7zJ49bmEQGOIw3lBVnBJotupYH8We82+31lICcKdwNAhLwRD\nowCNKPHrgRwpMohz33r/vkjf/QsGLW2xstrqk+ZZqqEtANHnSfnTxU9XJIiJ\nlVkXZ/5cpTwvCGOLapSiHUG8bYhZikxr9CSM0fMCnuwlYGbhd+o9FoWOIVpg\nQZHfxioyramL6GmiXZ15FvRS3Gd3pjjATZY/wv19LQkv1NJSugyGx1X6fj5D\n8tf1Yh7OVDueY9gtYs+oV+d64czbvW/q30MKWgf5EipiS4ZA2PSEYNMP9OWo\nf9J4AVAMupTz2usGyX/3rF2r2JhsZMVLcuBlaBbi0GZcyGkiMmCl/+f7fRTc\nIVLCuzqftyh9VAQyj6T2x2fe3S0ivfJFVwEnF4QJ/K4+j9qgnkN9aGXX4UkU\nMKtBrnZ8BmtMn0FBQWicz1JeGX+YGmcT476uj2psxxJS\n=3Go2\n-----END PGP MESSAGE-----\n';
11 const folderName =
12     '-----BEGIN PGP MESSAGE-----\nVersion: ProtonMail\n\nwV4D7bIbvfUVIgMSAQdAo0jDKpBeHzQDAjGPYPgMjLUFa3Rfs2U1c/XJxD69\njRow+Hz5SU5CAkSJmSHHYsctlaCcsRCfmkl62A5JIXfV/wHRDk0Usi6NIstq\n3aD+ywyr0j8BNY0gX2w08fWEyMDGAcYeqJay0zmsPRg9l59XYySAOAShlVvN\nQa/vQWCAxl/Bk1iYctxCPCDVslSMYRJeG2A=\n=Lj9p\n-----END PGP MESSAGE-----\n'.trim();
14 describe('drive keys', () => {
15     it('should prepare drive keys', async () => {
16         const decryptedPrivateKey = await CryptoProxy.importPrivateKey({
17             armoredKey: addressKey,
18             passphrase: 'oXueLX2EKIM.mwS7qmU2wvfNXb3KI3i',
19         });
20         const decryptedPassphrase = await decryptUnsigned({
21             armoredMessage: passphrase,
22             privateKey: decryptedPrivateKey,
23         });
25         const decryptedShareKey = await CryptoProxy.importPrivateKey({
26             armoredKey: shareKey,
27             passphrase: decryptedPassphrase,
28         });
29         const decryptedFolderName = await decryptUnsigned({
30             armoredMessage: folderName,
31             privateKey: decryptedShareKey,
32         });
34         expect(decryptedFolderName).toBe('folder1');
35     });
36 });