Skip to content

Commit 679b3e1

Browse files
committed
[tmp] remove postprocessing steps
TODO: come back and reenable all of this
1 parent e7710c5 commit 679b3e1

2 files changed

Lines changed: 3 additions & 47 deletions

File tree

src/processing/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616

1717
export { preprocessFile, validateDocument } from './preprocess';
1818
export { generateHashesForDocument, processFile } from './process';
19-
export { postprocessFile, encryptFile } from './postprocess';
19+
export { postprocessFile } from './postprocess';
2020
export { keepOutputColumns } from './mapping';

src/processing/postprocess.ts

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,13 @@
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
import * as openpgp from 'openpgp';
18-
import { createReadStream, createWriteStream, readFileSync } from 'fs';
19-
import { pipeline } from 'stream/promises';
20-
import { Readable } from 'stream';
21-
2217
import type { Config } from '../config/Config';
2318

2419
import Debug from 'debug';
2520
const log = Debug('CID:postprocessFile');
2621

2722

28-
export interface PostprocessFileResult {
29-
encryptedFilePath?: string
30-
}
23+
export interface PostprocessFileResult {}
3124

3225
interface PostprocessFileInput {
3326
config: Config.FileConfiguration,
@@ -36,45 +29,8 @@ interface PostprocessFileInput {
3629

3730
export async function postprocessFile({ config, filePath }: PostprocessFileInput): Promise<PostprocessFileResult> {
3831
log('------------ postprocessFile -----------------');
39-
let encryptedFilePath: string | undefined;
4032

4133
if (!config.post_processing) return {}
4234

43-
if (config.post_processing.encryption) {
44-
encryptedFilePath = await encryptFile({
45-
filePath: filePath,
46-
keyPath: config.post_processing.encryption.key_path
47-
});
48-
}
49-
50-
return {
51-
encryptedFilePath
52-
}
53-
}
54-
55-
56-
type EncryptFileInput = {
57-
filePath: string;
58-
keyPath: string;
59-
}
60-
export async function encryptFile({ filePath, keyPath }: EncryptFileInput) {
61-
const publicKeyArmoured = readFileSync(keyPath, "utf-8");
62-
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmoured });
63-
64-
const webStream = Readable.toWeb(createReadStream(filePath));
65-
66-
const encryptionStream = await openpgp.encrypt({
67-
message: await openpgp.createMessage({ binary: webStream }),
68-
encryptionKeys: publicKey,
69-
format: "binary"
70-
});
71-
72-
const outputPath = `${filePath}.gpg`;
73-
74-
const nodeWritable = createWriteStream(outputPath);
75-
const nodeReadable = Readable.fromWeb(encryptionStream);
76-
77-
await pipeline(nodeReadable, nodeWritable);
78-
79-
return outputPath;
35+
return {}
8036
}

0 commit comments

Comments
 (0)