Skip to content

Commit

Permalink
Merge pull request #1416 from internxt/chore/remove_dead_code
Browse files Browse the repository at this point in the history
[_] remove dead code
  • Loading branch information
TamaraFinogina authored Jan 14, 2025
2 parents e531459 + 9705c0a commit 189648f
Showing 1 changed file with 0 additions and 66 deletions.
66 changes: 0 additions & 66 deletions src/app/crypto/services/utilspgp.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { DecryptMessageResult, WebStream } from 'openpgp';
import localStorageService from '../../core/services/local-storage.service';
import { getOpenpgp } from './pgp.service';

export async function isValidBase64(key: string): Promise<boolean> {
Expand All @@ -17,67 +15,3 @@ export async function isValid(key: string): Promise<boolean> {
return false;
}
}

export async function decryptPGP(armoredMessage: string): Promise<DecryptMessageResult> {
const user = localStorageService.getUser();
const openpgp = await getOpenpgp();

if (!user) {
throw Error('User not found on local storage');
}

// User settings
const privateKey = Buffer.from(user.privateKey, 'base64').toString();
const publicKey = Buffer.from(user.publicKey, 'base64').toString();

// Prepare input
const cipherText = await openpgp.readMessage({ armoredMessage });
const publicKeyArmored = await openpgp.readKey({ armoredKey: publicKey });
const privateKeyArmored = await openpgp.readPrivateKey({ armoredKey: privateKey });

// Decrypt message
return openpgp.decrypt({
message: cipherText,
verificationKeys: publicKeyArmored,
decryptionKeys: privateKeyArmored,
});
}

export async function encryptPGP(message: string): Promise<WebStream<string>> {
const user = localStorageService.getUser();
const openpgp = await getOpenpgp();

if (!user) {
throw Error('User not found on local storage');
}

// User settings
const publicKey = Buffer.from(user.publicKey, 'base64').toString();

// Prepare input
const originalText = await openpgp.createMessage({ text: message });
const publicKeyArmored = await openpgp.readKey({ armoredKey: publicKey });

// Encrypt message
return openpgp.encrypt({
message: originalText,
encryptionKeys: publicKeyArmored,
});
}

export async function encryptPGPInvitations(message: string, key: string): Promise<WebStream<string>> {
const openpgp = await getOpenpgp();

// User settings
const publicKey = Buffer.from(key, 'base64').toString();

// Prepare input
const originalText = await openpgp.createMessage({ text: message });
const publicKeyArmored = await openpgp.readKey({ armoredKey: publicKey });

// Encrypt message
return openpgp.encrypt({
message: originalText,
encryptionKeys: publicKeyArmored,
});
}

0 comments on commit 189648f

Please sign in to comment.